private static Method requiredMethod(Class clazz) {
    if (MessageEncoder.class.isAssignableFrom(clazz)) {
      try {
        Method methodInstance = clazz.getMethod("getInstance");
        if (MessageEncoder.class.isAssignableFrom(methodInstance.getReturnType())) {
          int modifiers = methodInstance.getModifiers();
          if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
            return methodInstance;
          }
          throw new NoSuchMethodException(
              "modifier for getInstance() method is not 'public static' in " + clazz
                  .getCanonicalName());
        }
        throw new NoSuchMethodException(
            "return type is not assignable to " + MessageEncoder.class.getCanonicalName());
      } catch (NoSuchMethodException e) {
        String message = clazz.getCanonicalName()
            + " does not implement the required 'public static MessageEncoder getInstance()' method ";
        LOG.error(message, e);
        throw new IllegalArgumentException(message, e);
      }
    }
    String message = clazz.getCanonicalName() + " is not assignable to " + MessageEncoder.class
        .getCanonicalName();
    LOG.error(message);
    throw new IllegalArgumentException(message);
  }
Abstract Factory for the construction of HCatalog message instances.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java