Create a Trie containing the enum constants of an {@code Enum}.

@param enumClass Enum class to create Trie for.
@param <E> Actual Enum type.
@return A Trie containing the enum constants of the given {@code Enum}.
180570
public static <E extends Enum<E>> Trie<E> enumTrie(Class<E> enumClass) {
        final TrieBuilder<E> builder = new TrieBuilder<>();
        for (E value : enumClass.getEnumConstants()) {
            builder.add(value.toString(), value);
        }
        return builder.build();
    }
66344
protected <A extends Enum<A>> EnumPath<A> createEnum(String property, Class<A> type) {
        return add(new EnumPath<A>(type, forProperty(property)));
    }
156049
def _create_enum_class(ffi, type_name, prefix, flags=False):
    """"""

    class _template(int):
        _map = {}

        @property
        def value(self):
            return int(self)

        def __str__(self):
            return self._map.get(self, "Unknown")

        def __repr__(self):
            return "%s.%s" % (type(self).__name__, str(self))

    class _template_flags(int):
        _map = {}

        @property
        def value(self):
            return int(self)

        def __str__(self):
            names = []
            val = int(self)
            for flag, name in self._map.items():
                if val & flag:
                    names.append(name)
                    val &= ~flag
            if val:
                names.append(str(val))
            return " | ".join(sorted(names or ["Unknown"]))

        def __repr__(self):
            return "%s(%s)" % (type(self).__name__, str(self))

    if flags:
        template = _template_flags
    else:
        template = _template

    cls = type(type_name, template.__bases__, dict(template.__dict__))
    prefix_len = len(prefix)
    for value, name in ffi.typeof(type_name).elements.items():
        assert name[:prefix_len] == prefix
        name = name[prefix_len:]
        setattr(cls, name, cls(value))
        cls._map[value] = name

    return cls
849937
public static <E extends Enum<E> & ByteEnum> E fromByte (Class<E> eclass, byte code)
    {
        for (E value : eclass.getEnumConstants()) {
            if (value.toByte() == code) {
                return value;
            }
        }
        throw new IllegalArgumentException(eclass + " has no value with code " + code);
    }
1236223
@SuppressWarnings("unchecked") // the cache always returns the type matching enumType
    public static <T extends Enum<T>> T[] getSharedConstants(Class<T> enumType) {
        return (T[]) sharedConstantsCache.get(enumType);
    }
142389
public static <E extends Enum<E>> EnumKeyDeserializer<E> newInstance( Class<E> enumClass ) {
        return new EnumKeyDeserializer<E>( enumClass );
    }
494342
private ClassNode makeType(ClassNode cn, boolean usingClass) {
        if (usingClass) {
            ClassNode clazzType = CLASS_Type.getPlainNodeReference();
            clazzType.setGenericsTypes(new GenericsType[] {new GenericsType(cn)});
            return clazzType;
        } else {
            return cn;
        }
    }
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;
  }
276668
public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass)
    {
        return createFrom(typeClass, NO_EXCLUSIONS, ID_STRATEGY);
    }
120964
public static TypeRepresentation ofEnum(final TypeIdentifier identifier, final String... enumValues) {
        return new EnumTypeRepresentation(identifier, new HashSet<>(Arrays.asList(enumValues)));
    }
1222812
public static <T extends Enum<T>> IAccessor<T> createAccessor(Class<T> clazz) {
        return new EnumOrderAccessor<T>(clazz);
    }
1252616
public static <K extends Enum<K> & Keyed<String>> EnumLookup<K, String> of(final Class<K> enumClass,
                                                                               final boolean caseSensitive) {
        return new EnumLookup<K, String>(enumClass, -1, caseSensitive);
    }
782901
public <T extends Enum<T>> T getParameterAsEnum(String name, Class<T> type, T defaultValue) {
		return defaultValue(stringToEnum(getParameter(name), type), defaultValue);
	}
773394
public static <E> JpaRepositoryConfig<E> create(Class<E> entityClass) {
        return builder(entityClass).build();
    }
688107
public Map<String, Enum<?>> getEnumRenames(Class<?> type) {
        if (type == null) {
            throw new IllegalArgumentException("type must not be null");
        }
        Map<String, Enum<?>> map = enumRenames.get(type);
        if (map == null) {
            return new HashMap<String, Enum<?>>();
        }
        return new HashMap<String, Enum<?>>(map);
    }
271708
public static <T extends Enum<T>> T convert(Class<T> type, String name, T defaultValue) {
        if (name == null) {
            return defaultValue;
        }

        for (T e : type.getEnumConstants()) {
            if (e.name().equalsIgnoreCase(name)) {
                return e;
            }
        }

        return defaultValue;
    }
110473
private List<Map<String, Object>> docForEnumArgument(final Class<?> enumClass) {
        final ClassDoc doc = this.getDoclet().getClassDocForClass(enumClass);
        if ( doc == null ) {
            throw new RuntimeException("Tried to get docs for enum " + enumClass + " but got null instead");
        }

        final Set<String> enumConstantFieldNames = enumConstantsNames(enumClass);
        final List<Map<String, Object>> bindings = new ArrayList<Map<String, Object>>();
        for (final FieldDoc fieldDoc : doc.fields(false)) {
            if (enumConstantFieldNames.contains(fieldDoc.name()) ) {
                bindings.add(
                        new HashMap<String, Object>() {
                            static final long serialVersionUID = 0L;
                            {
                                put("name", fieldDoc.name());
                                put("summary", fieldDoc.commentText());
                            }
                        }
                );
            }
        }

        return bindings;
    }