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:it.unimi.dsi.util.Properties.java
public Short getShort(final Enum<?> key, Short arg) { return getShort(key.name().toLowerCase(), arg); }
From source file:de.escalon.hypermedia.hydra.serialize.JacksonHydraSerializer.java
private Map<String, Object> getTerms(Object bean, Class<?> mixInClass) throws IntrospectionException, IllegalAccessException, NoSuchFieldException { // define terms from package or type in context final Class<?> beanClass = bean.getClass(); Map<String, Object> termsMap = getAnnotatedTerms(beanClass.getPackage(), beanClass.getPackage().getName()); Map<String, Object> classTermsMap = getAnnotatedTerms(beanClass, beanClass.getName()); Map<String, Object> mixinTermsMap = getAnnotatedTerms(mixInClass, beanClass.getName()); // class terms override package terms termsMap.putAll(classTermsMap);/*w ww. jav a 2 s. co m*/ // mixin terms override class terms termsMap.putAll(mixinTermsMap); final Field[] fields = beanClass.getDeclaredFields(); for (Field field : fields) { final Expose fieldExpose = field.getAnnotation(Expose.class); if (Enum.class.isAssignableFrom(field.getType())) { Map<String, String> map = new LinkedHashMap<String, String>(); termsMap.put(field.getName(), map); if (fieldExpose != null) { map.put(AT_ID, fieldExpose.value()); } map.put(AT_TYPE, AT_VOCAB); final Enum value = (Enum) field.get(bean); final Expose enumValueExpose = getAnnotation(value.getClass().getField(value.name()), Expose.class); // TODO redefine actual enum value to exposed on enum value definition if (enumValueExpose != null) { termsMap.put(value.toString(), enumValueExpose.value()); } else { // might use upperToCamelCase if nothing is exposed final String camelCaseEnumValue = WordUtils .capitalizeFully(value.toString(), new char[] { '_' }).replaceAll("_", ""); termsMap.put(value.toString(), camelCaseEnumValue); } } else { if (fieldExpose != null) { termsMap.put(field.getName(), fieldExpose.value()); } } } // TODO do this recursively for nested beans and collect as long as // nested beans have same vocab // expose getters in context final BeanInfo beanInfo = Introspector.getBeanInfo(beanClass); final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { final Method method = propertyDescriptor.getReadMethod(); final Expose expose = method.getAnnotation(Expose.class); if (expose != null) { termsMap.put(propertyDescriptor.getName(), expose.value()); } } return termsMap; }
From source file:it.unimi.dsi.util.Properties.java
public List<?> getList(final Enum<?> key, List<?> arg) { return getList(key.name().toLowerCase(), arg); }
From source file:it.unimi.dsi.util.Properties.java
public double getDouble(final Enum<?> key, double arg) { return getDouble(key.name().toLowerCase(), arg); }
From source file:it.unimi.dsi.util.Properties.java
public Double getDouble(final Enum<?> key, Double arg) { return getDouble(key.name().toLowerCase(), arg); }
From source file:it.unimi.dsi.util.Properties.java
public String getString(final Enum<?> key, String arg) { return getString(key.name().toLowerCase(), arg); }
From source file:it.unimi.dsi.util.Properties.java
public void addProperty(final Enum<?> key, final int i) { super.addProperty(key.name().toLowerCase(), Integer.valueOf(i)); }
From source file:it.unimi.dsi.util.Properties.java
public void setProperty(final Enum<?> key, final int i) { super.setProperty(key.name().toLowerCase(), Integer.valueOf(i)); }
From source file:it.unimi.dsi.util.Properties.java
public boolean getBoolean(final Enum<?> key, boolean arg) { return getBoolean(key.name().toLowerCase(), arg); }
From source file:it.unimi.dsi.util.Properties.java
public Boolean getBoolean(final Enum<?> key, Boolean arg) { return getBoolean(key.name().toLowerCase(), arg); }