The factory method
@param theClass the enum class
@param <T> the enum type
@return the rich enum companion class instance
182263
public static <T extends Enum<T> & RichEnum<T>> RichEnumConstants<T> richConstants(Class<T> theClass) {
        return new RichEnumConstants<>(theClass);
    }
1202011
public <T extends Enum<T>> T getEnum(String name, Class<T> declaringClass) {
    final String val = get(name);
    Preconditions.checkNotNull(val);
    return Enum.valueOf(declaringClass, val);
  }
1070067
public <T extends Enum<T>> T readEnum(Class<T> enumType) throws IOException {
		try {
			return Enum.valueOf(enumType, readUTF());
		} catch(IllegalArgumentException err) {
			throw new IOException(err);
		}
	}
1088222
@Nullable
    public <T> Provider<T> getFactory(Class<T> classDefinition) {
        //noinspection unchecked
        return factories.getRootValue().get(classDefinition);
    }
142389
public static <E extends Enum<E>> EnumKeyDeserializer<E> newInstance( Class<E> enumClass ) {
        return new EnumKeyDeserializer<E>( enumClass );
    }
50809
public <T extends Enum<T>> T getEnum(Class<T> enumType, String key) {
    if (enumType == null) {
      throw new IllegalArgumentException("enumType may not be null");
    }
    Object value = get(key);
    if (enumType.isInstance(value)) {
      //noinspection unchecked
      return (T) value;
    } else if (value instanceof String) {
      String stringValue = (String) value;
      return Enum.valueOf(enumType, stringValue);
    }
    return null;
  }
840983
public static <T> T getInstance(Class<T> beanClass, String beanName) {
		return (T) getInstanceProvider().getInstance(beanClass, beanName);
	}
1014503
public static <T extends Enum<T>> Translator<T> getEnumTranslator(final Class<T> enumType)
    {
        return new Translator<T>()
        {
            @Override
            public String getPropertyName(T propertyKey)
            {
                return propertyKey.name().toLowerCase().replace('_', '.');
            }

            @Override
            public T getPropertyKey(String propertyName)
            {
                String enumName = propertyName.toUpperCase().replace('.', '_');
                return Enum.valueOf(enumType, enumName);
            }
        };
    }
751202
public <T extends Enum<T>> EnumSet<T> getParametersAsEnums(String name, Class<T> type, EnumSet<T> defaultValue) {
		String[] enumNames = getParameters(name);
		if (enumNames == null) {
			return defaultValue;
		} else {
			Collection<T> enums = new ArrayList<>();
			for (String enumName : enumNames) {
				T enumValue = stringToEnum(blankToNull(enumName), type);
				if (enumValue != null) {
					enums.add(enumValue);
				}
			}
			return enums.isEmpty() ? defaultValue : EnumSet.copyOf(enums);
		}
	}
236468
public static Map<String, Class> buildTypeParamImplLookup(Class theClass) {
        Map<String, Class> lookup = new HashMap<>();
        buildTypeParamImplLookup(theClass, lookup);
        return lookup;
    }
660926
@SuppressWarnings("unchecked")
  public static <T> T newInstance(Class<T> theClass, Configuration conf) {
    return newInstance(theClass, conf, true);
  }
73898
public static <T extends Annotation> T getAnnotation(final Class<?> componentClass,
		final Class<T> annotationClass)
	{
		T annotation = componentClass.getAnnotation(annotationClass);
		if (annotation != null)
		{
			return annotation;
		}
		for (final Class<?> ifc : componentClass.getInterfaces())
		{
			annotation = getAnnotation(ifc, annotationClass);
			if (annotation != null)
			{
				return annotation;
			}
		}
		if (!Annotation.class.isAssignableFrom(componentClass))
		{
			for (final Annotation ann : componentClass.getAnnotations())
			{
				annotation = getAnnotation(ann.annotationType(), annotationClass);
				if (annotation != null)
				{
					return annotation;
				}
			}
		}
		final Class<?> superClass = componentClass.getSuperclass();
		if (superClass == null || superClass.equals(Object.class))
		{
			return null;
		}
		return getAnnotation(superClass, annotationClass);
	}
884878
public static final <T> T defaultFactory(Class<T> cls, String hint)
    {
        try
        {
            return cls.newInstance();
        }
        catch (InstantiationException | IllegalAccessException ex)
        {
            throw new IllegalArgumentException(ex);
        }
    }
582044
public static TProcessorFactory processorFactoryToTProcessorFactory(final NiftyProcessorFactory niftyProcessorFactory)
    {
        return new TProcessorFactory(null) {
            @Override
            public TProcessor getProcessor(TTransport trans)
            {
                return processorToTProcessor(niftyProcessorFactory.getProcessor(trans));
            }
        };
    }
1046264
public static NiftyProcessorFactory factoryFromTProcessorFactory(final TProcessorFactory standardThriftProcessorFactory)
    {
        checkProcessMethodSignature();

        return new NiftyProcessorFactory()
        {
            @Override
            public NiftyProcessor getProcessor(TTransport transport)
            {
                return processorFromTProcessor(standardThriftProcessorFactory.getProcessor
                        (transport));
            }
        };
    }
194027
public <T extends Enum<T>> boolean registerEnum(Class<T> enumClass)
    {
        return null == enumMapping.putIfAbsent(enumClass.getName(),
                EnumIO.newEnumIO(enumClass, this));
    }
1206363
public static <E extends Enum<E>> LinkedHashMap<String, E> getEnumMap(final Class<E> enumClass) {
		final LinkedHashMap<String, E> map = new LinkedHashMap<String, E>();
		for (final E e : enumClass.getEnumConstants()) {
			map.put(e.name(), e);
		}
		return map;
	}