Returns first enum constant found..

@param styleName    Space-separated list of styles
@param enumClass    Type of enum
@param defaultValue Default value of no match was found
@return First enum constant found or default value
507187
public static <E extends Enum<? extends Style.HasCssName>> E fromStyleName(final String styleName,
                                                                               final Class<E> enumClass,
                                                                               final E defaultValue) {
        return EnumHelper.fromStyleName(styleName, enumClass, defaultValue, true);
    }
438110
@SuppressWarnings("unchecked")
    static <T> T getEnumValue(Class<T> cls, String name) {
        HashMap<String, Object> enumMap = enumMaps.get(cls);
        if (enumMap == null) {
            T[] consts = cls.getEnumConstants();
            enumMap = new HashMap<String, Object>(consts.length);
            for (T e : consts) {
                enumMap.put(((Enum<?>) e).toString(), e);
            }
            enumMaps.put(cls, enumMap);
        }
        T v = (T) enumMap.get(name);
        if (v == null) {
            v = (T) enumMap.get("Other");
        }
        return v;
    }
92874
public <T extends Enum<T>> ThriftEnumMetadata<?> getThriftEnumMetadata(Class<?> enumClass)
    {
        ThriftEnumMetadata<?> enumMetadata = enums.get(enumClass);
        if (enumMetadata == null) {
            enumMetadata = new ThriftEnumMetadataBuilder<>((Class<T>) enumClass).build();

            ThriftEnumMetadata<?> current = enums.putIfAbsent(enumClass, enumMetadata);
            if (current != null) {
                enumMetadata = current;
            }
        }
        return enumMetadata;
    }
1034312
public String getProperty(String key, String defaultValue) {
        String value = getProperty(key, String.class);
        return StringUtils.isEmpty(value) ? defaultValue : value;
    }
977781
@Override
    public String getDefaultMetaVariable() {
    	StringBuffer rv = new StringBuffer();
    	rv.append("[");
    	for (T t : enumType.getEnumConstants()) {
			rv.append(t).append(" | ");
		}
    	rv.delete(rv.length()-3, rv.length());
    	rv.append("]");
    	return rv.toString();
    }
928001
private String getCustSerializedEnumValue(EnumValueOptions options, String defaultValue) {
    for (Extension<EnumValueOptions, String> extension : serializedEnumValueExtensions) {
      if (options.hasExtension(extension)) {
        return options.getExtension(extension);
      }
    }
    return defaultValue;
  }
1244598
@Nullable
  public static <ENUMTYPE extends Enum <ENUMTYPE> & IHasName> ENUMTYPE getFromNameCaseInsensitiveOrNull (@Nonnull final Class <ENUMTYPE> aClass,
                                                                                                         @Nullable final String sName)
  {
    return getFromNameCaseInsensitiveOrDefault (aClass, sName, null);
  }
916342
public final String getStyleProperty(StyleName styleName) {
        return styleProps!=null ? styleProps.get(styleName) : null;
    }
1074466
@Nullable
  public static <ENUMTYPE extends Enum <ENUMTYPE> & IHasIntID> ENUMTYPE getFromIDOrNull (@Nonnull final Class <ENUMTYPE> aClass,
                                                                                         final int nID)
  {
    return getFromIDOrDefault (aClass, nID, null);
  }
736490
public <TEnum extends Enum<TEnum>> TEnum get(Enum<?> key, Class<TEnum> enumClass, TEnum defaultValue)
    {
        return getEnum(key, enumClass, defaultValue);
    }
994194
public <TEnum extends Enum<TEnum>> TEnum getEnum(String key, Class<TEnum> enumClass, TEnum defaultValue)
    {
        String name = getString(key);

        if (name == null)
        {
            return defaultValue;
        }

        try
        {
            return Enum.valueOf(enumClass, name);
        }
        catch (RuntimeException e)
        {
            return defaultValue;
        }
    }
1073398
public final void setDefaultStyle(final Map<String, Style> defaultStyle) {
        this.defaultStyle = new HashMap<>(defaultStyle.size());
        for (Map.Entry<String, Style> entry: defaultStyle.entrySet()) {
            String normalizedName = GEOMETRY_NAME_ALIASES.get(entry.getKey().toLowerCase());

            if (normalizedName == null) {
                normalizedName = entry.getKey().toLowerCase();
            }

            this.defaultStyle.put(normalizedName, entry.getValue());
        }
    }
363159
private <T extends Enum<T>> Object[] getValidEnumConstants(Class<T> valueClass) {
        T[] constants = valueClass.getEnumConstants();
        if (!VersionedEnum.class.isAssignableFrom(valueClass)) {
            return constants;
        }

        List<T> valid = new ArrayList<T>(constants.length);
        for (T value : constants) {
            VersionedEnum versionedValue = (VersionedEnum) value;
            if (version >= versionedValue.getMinVersion()) {
                valid.add(value);
            }
        }

        return valid.toArray();
    }
313624
public static <T> Optional<Class<T>> getElementValueClass(AnnotationMirror anno, CharSequence name,
                                                              boolean useDefaults) {
        Name cn = getElementValueClassName(anno, name, useDefaults);
        try {
            Class<?> cls = Class.forName(cn.toString());
            return Optional.of((Class<T>) cls);
        } catch (ClassNotFoundException e) {
            return Optional.empty();
        }
    }
1060996
private String firstConstantOfEnum()
    {
        Object[] enumConstants = targetClass.getEnumConstants();

        if (enumConstants.length != 0)
        {
            return enumConstants[0].toString();
        }

        return ""; // if empty Enum
    }
464735
public static <T extends Enum<T>> ConfigurationOptionBuilder<T> enumOption(Class<T> clazz) {
		final ConfigurationOptionBuilder<T> optionBuilder = new ConfigurationOptionBuilder<T>(new EnumValueConverter<T>(clazz), clazz);
		for (T enumConstant : clazz.getEnumConstants()) {
			optionBuilder.addValidOption(enumConstant);
		}
		optionBuilder.sealValidOptions();
		return optionBuilder;
	}
1105966
public boolean getBoolean(Enum<?> key, boolean defaultValue)
    {
        if (key == null)
        {
            return defaultValue;
        }

        return getBoolean(key.name(), defaultValue);
    }