List of usage examples for java.lang Enum name
String name
To view the source code for java.lang Enum name.
Click Source Link
From source file:com.anrisoftware.sscontrol.core.groovy.statementsmap.StatementsEnumToString.java
/** * Returns the statements key name from the statement enumeration constant. * * @param statementsEnum// w ww. ja v a2 s. c o m * the enumeration {@link Enum} constant. * * @return the statement key {@link String} name. */ public static String toString(Enum<?> statementsEnum) { String[] split = split(lowerCase(statementsEnum.name()), SEPERATOR); for (int i = 1; i < split.length - 1; i++) { split[i] = WordUtils.capitalize(split[i]); } String name = join(split, EMPTY, 0, split.length - 1); return name; }
From source file:org.amanzi.neo.nodetypes.NodeTypeUtils.java
public static String getTypeId(final Enum<? extends INodeType> enumItem) { assert enumItem != null; return enumItem.name().toLowerCase(Locale.getDefault()); }
From source file:energy.usef.core.workflow.util.WorkflowUtil.java
/** * Validate the context based on all Enum values. * /*from ww w .j a v a 2 s. c om*/ * @param name - The name of the Workflow Step we are currently in. * @param context - The {@link WorkflowContext} to validate. * @param values - The required enum keys. */ public static void validateContext(String name, WorkflowContext context, @SuppressWarnings("rawtypes") Enum[] values) { List<String> nullProperties = new ArrayList<>(); for (@SuppressWarnings("rawtypes") Enum value : values) { String requiredProperty = value.name(); if (context.getValue(requiredProperty) == null) { nullProperties.add(requiredProperty); } } if (!nullProperties.isEmpty()) { StringBuilder message = new StringBuilder("WorkflowContext validation failed for "); message.append(name); message.append(System.lineSeparator()); message.append("The following propeties are missing: "); message.append(StringUtils.join(nullProperties, ", ")); throw new WorkflowException(message.toString()); } }
From source file:org.springframework.social.google.api.impl.ApiEnumSerializer.java
public static String enumToString(Enum<?> value) { if (value == null) { return null; }// w w w.j a v a2 s. co m String underscored = value.name(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < underscored.length(); i++) { char c = underscored.charAt(i); if (c == '_') { sb.append(Character.toUpperCase(underscored.charAt(++i))); } else { sb.append(Character.toLowerCase(c)); } } return sb.toString(); }
From source file:gov.nih.nci.firebird.common.FirebirdEnumUtils.java
/** * @param enumeration enumeration to convert * @return a String display of the enumeration. Replaces all "_" with spaces and capitalizes first letter of each * word./*from w w w. jav a 2s . c om*/ */ public static String getEnumDisplay(Enum<?> enumeration) { return WordUtils.capitalizeFully(StringUtils.replace(enumeration.name(), "_", " ")); }
From source file:Main.java
/** * @param clazz// ww w .java 2s . c o m * @return namespace of root element qname or null if this is not object does not represent a root element */ public static String getEnumValue(Enum<?> myEnum) { Field f; String value; try { f = myEnum.getClass().getField(myEnum.name()); f.setAccessible(true); XmlEnumValue xev = (XmlEnumValue) getAnnotation(f, XmlEnumValue.class); if (xev == null) { value = f.getName(); } else { value = xev.value(); } } catch (SecurityException e) { value = null; } catch (NoSuchFieldException e) { value = null; } return value; }
From source file:com.netflix.simianarmy.aws.AbstractRecorder.java
/** * Enum to value. Converts an enum to "name|type" string * * @param e//from ww w. j a v a 2 s . c om * the e * @return the string */ protected static String enumToValue(Enum e) { return String.format("%s|%s", e.name(), e.getClass().getName()); }
From source file:nl.strohalm.cyclos.utils.EnumHelper.java
/** * Capitalizes an enum item name/*from w ww . jav a2 s . co m*/ */ public static String capitalizeName(final Enum<?> item) { final String capitalized = StringUtils.replace(WordUtils.capitalizeFully(item.name(), new char[] { '_' }), "_", ""); return Character.toLowerCase(capitalized.charAt(0)) + capitalized.substring(1); }
From source file:com.wavemaker.tools.apidocs.tools.parser.util.DataTypeUtil.java
/** * It will parse the given {@link Class} as {@link Enum}, returns the list of values of given {@link Enum} * * @param type data type//from w w w . java 2 s.c o m * @param <E> data type * @return {@link List} of enum name Strings. * @throws IllegalArgumentException when given type is not an {@link Enum}. */ public static <E> List<String> getEnumValues(Class<E> type) { if (isEnum(type)) { Class<Enum> enumClass = (Class<Enum>) type; List<String> values = new ArrayList<>(enumClass.getEnumConstants().length); for (Enum anEnum : enumClass.getEnumConstants()) { values.add(anEnum.name()); } return values; } else { throw new IllegalArgumentException("Given type is not a Enum"); } }
From source file:edu.utah.further.core.api.discrete.EnumUtil.java
/** * Return a default title case string of an enumerated type. The constant's name is * converted to lower case, except the first character, which is capitalized. * Underscore symbols are replaced by white spaces, for improved readability. * * @param enumVal/* w w w . j a va 2s . com*/ * The enumerated value to translate * * @return a default title case string */ public static String getDisplayString(final Enum<?> enumVal) { return capitalize(replaceChars(lowerCase(enumVal.name()), ENUM_NAME_SEPARATOR, SPACE_STRING)); }