List of usage examples for java.lang Enum getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:net.sf.jasperreports.engine.util.JRApiWriter.java
/** * *//*from w w w .ja v a 2s .co m*/ protected void write(String pattern, Enum<?> value, Enum<?> defaultValue) { if (value != null && value != defaultValue) { write(MessageFormat.format(pattern, new Object[] { value.getClass().getName() + "." + value.name() })); } }
From source file:org.apache.axis2.jaxws.utility.XMLRootElementUtil.java
/** * @param clazz//from w w w. j ava 2 s . co m * @return namespace of root element qname or null if this is 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:org.apache.openjpa.persistence.AnnotationBuilder.java
static String enumToString(Enum e) { StringBuilder sb = new StringBuilder(); sb.append(Strings.getClassName(e.getClass())).append(".").append(e); return sb.toString(); }
From source file:org.apache.tapestry.util.io.EnumAdaptor.java
public String squeeze(DataSqueezer squeezer, Object o) throws IOException { Enum e = (Enum) o; return PREFIX + e.getClass().getName() + SEPARATOR + e.getName(); }
From source file:org.ardverk.gibson.EventUtils.java
private static void append(MessageDigest md, Enum<?> value) { append(md, value.getClass()); append(md, value.name()); }
From source file:org.fenixedu.academic.util.phd.PhdBundleUtil.java
@Deprecated public static String getEnumName(final Enum<?> enumeration, final String moduleName) { String enumFullName = enumeration.getClass().getName(); if (enumFullName.indexOf('$') > -1) { enumFullName = enumFullName.substring(0, enumFullName.indexOf('$')); }// w ww. jav a2 s . c o m String enumSimpleName = enumeration.getClass().getSimpleName(); if (enumSimpleName.isEmpty()) { enumSimpleName = enumFullName.substring(enumFullName.lastIndexOf('.') + 1); } enumFullName = enumFullName + "." + enumeration.name(); enumSimpleName = enumSimpleName + "." + enumeration.name(); try { return getResourceBundleByModuleName(moduleName).getString(enumFullName); } catch (MissingResourceException e) { try { return getResourceBundleByModuleName(moduleName).getString(enumSimpleName); } catch (MissingResourceException ex) { try { return getResourceBundleByModuleName(moduleName).getString(enumeration.name()); } catch (MissingResourceException exc) { return enumFullName; } } } }
From source file:org.netxilia.api.impl.format.EnumerationFormatter.java
private String enumValue(String enumValueProperty, Enum<?> enumItem) { if (enumValueProperty == null || ENUM_VALUE_NAME.equals(enumValueProperty)) { return enumItem.name(); }//w w w .j a v a2 s. c o m if (ENUM_VALUE_ORDINAL.equals(enumValueProperty)) { return String.valueOf(enumItem.ordinal()); } try { return BeanUtils.getSimpleProperty(enumItem, enumValueProperty); } catch (Exception e) { throw new IllegalArgumentException("Unknown property:" + enumItem.getClass() + "." + enumValueProperty); } }
From source file:org.ow2.sirocco.cloudmanager.core.utils.QueryHelper.java
/** * code factoring for getXXX (getMachines, getVolumes,etc) * //from ww w. j a v a2s. c o m * @param entityType * @param em * @param tenantId optional, filter request to given tenant * @param verifyDeletedState if the query should ignore deleted entities.<br> * Must be set to false if an entity doesn't have a state field * @return */ @SuppressWarnings({ "rawtypes" }) public static List getEntityList(final String entityType, final EntityManager em, final Integer tenantId, final Enum stateToIgnore, final boolean returnPublicEntities) { String tenantQuery = "", stateQuery = ""; if (tenantId != null) { if (!returnPublicEntities) { tenantQuery = " v.tenant.id=:tenantId "; } else { tenantQuery = " (v.tenant.id=:tenantId OR v.visibility = org.ow2.sirocco.cloudmanager.model.cimi.extension.Visibility.PUBLIC) "; } } if (stateToIgnore != null) { if (tenantQuery.length() > 0) { stateQuery = " AND "; } stateQuery = stateQuery + " v.state<>" + stateToIgnore.getClass().getName() + "." + stateToIgnore.name() + " "; } return em.createQuery( "SELECT v FROM " + entityType + " v WHERE " + tenantQuery + stateQuery + " ORDER BY v.id DESC") .setParameter("tenantId", tenantId).getResultList(); }