List of usage examples for java.lang Enum getDeclaringClass
@SuppressWarnings("unchecked") public final Class<E> getDeclaringClass()
From source file:com.evolveum.midpoint.gui.api.page.PageBase.java
public static String createEnumResourceKey(Enum e) { return e.getDeclaringClass().getSimpleName() + "." + e.name(); }
From source file:at.treedb.db.Base.java
/** * Field constraint - given text field of a entity must be unique for a CI. * // www . ja v a 2s . c o m * @param dao * {@code DAOiface} (data access object) * @param update * update data * @param domain * {@code Domain} of the entity * @param ciID * ID of the CI * @param dbID * DB ID of the entity * @param fieldName * text field name * @param value * field value * @throws Exception */ @SuppressWarnings("unchecked") public static void checkConstraintsPerCI(DAOiface dao, UpdateMap update, int domain, int ciID, int dbID, Enum<?> fieldName, String value) throws Exception { List<Base> list = null; HashMap<String, Object> map = new HashMap<String, Object>(); map.put("domain", domain); map.put("status", at.treedb.db.HistorizationIface.STATUS.ACTIVE); Class<?> clazz = fieldName.getDeclaringClass().getDeclaringClass(); String entry = fieldName.name(); if (update == null) { map.put(entry, value); map.put("ciId", ciID); list = (List<Base>) dao .query("select i from " + clazz.getSimpleName() + " i where i.domain = :domain and i." + entry + " = :" + entry + " and i.status = :status and i.ci = :ciId", map); } else { Update m = update.get(fieldName); if (m != null) { map.put("histId", dbID); map.put("ciId", ciID); map.put("name", m.getString()); list = (List<Base>) dao.query("select i from " + clazz.getSimpleName() + " i where i.domain = :domain and i." + entry + " = :" + entry + " and i.ci =:ciId and i.status = :status and i.histId <> :histId", map); } } if (list != null && list.size() > 0) { throw new Exception( clazz.getSimpleName() + ".checkConstraints(): Property " + entry + " isn't unique:" + value); } }
From source file:at.treedb.db.Base.java
/** * Field constraint - given text field of an entity must be unique over all * domains.//w ww .j a v a2 s . com * * @param dao * {@code DAOiface} (data access object) * @param update * update data * @param dbID * DB ID of the entity * @param fieldName * text field name * @param value * field value * @throws Exception */ @SuppressWarnings("unchecked") public static void checkConstraint(DAOiface dao, UpdateMap update, int dbID, Enum<?> fieldName, String value) throws Exception { List<Base> list = null; HashMap<String, Object> map = new HashMap<String, Object>(); map.put("status", at.treedb.db.HistorizationIface.STATUS.ACTIVE); String entry = fieldName.name(); Class<?> clazz = fieldName.getDeclaringClass().getDeclaringClass(); if (update == null) { map.put(entry, value); list = (List<Base>) dao.query("select i from " + clazz.getSimpleName() + " i where i." + entry + " = :" + entry + " and i.status = :status", map); } else { Update m = update.get(fieldName); if (m != null) { map.put("histId", dbID); map.put(entry, m.getString()); list = (List<Base>) dao.query("select i from " + clazz.getSimpleName() + " i where i." + entry + " = :" + entry + " and i.status = :status and i.histId <> :histId", map); } } if (list != null && list.size() > 0) { throw new Exception( clazz.getSimpleName() + ".checkConstraints(): Property " + entry + " isn't unique:" + value); } }
From source file:at.treedb.db.Base.java
/** * Field constraint - given text field of an entity must be unique for a * domain.//from ww w . j a v a 2s.c o m * * @param dao * {@code DAOiface} (data access object) * @param update * update data * @param domain * {@code Domain} of the entity * @param dbID * ID of the entity * @param fieldName * text field name * @param value * field value * @throws Exception */ @SuppressWarnings("unchecked") public static void checkConstraintPerDomain(DAOiface dao, UpdateMap update, int domain, int dbID, Enum<?> fieldName, String value) throws Exception { List<Base> list = null; HashMap<String, Object> map = new HashMap<String, Object>(); map.put("domain", domain); map.put("status", at.treedb.db.HistorizationIface.STATUS.ACTIVE); String entry = fieldName.name(); Class<?> clazz = fieldName.getDeclaringClass().getDeclaringClass(); if (update == null) { map.put(entry, value); list = (List<Base>) dao.query("select i from " + clazz.getSimpleName() + " i where i.domain = :domain and i." + entry + " = :" + entry + " and i.status = :status", map); } else { Update m = update.get(fieldName); if (m != null) { map.put("histId", dbID); map.put("name", m.getString()); list = (List<Base>) dao .query("select i from " + clazz.getSimpleName() + " i where i.domain = :domain and i." + entry + " = :" + entry + " and i.status = :status and i.histId <> :histId", map); } } if (list != null && list.size() > 0) { throw new Exception( clazz.getSimpleName() + ".checkConstraints(): Property " + entry + " isn't unique:" + value); } }
From source file:mondrian.olap.Util.java
/** * Returns an exception indicating that we didn't expect to find this value * here.//from w ww . j a va 2 s .c o m */ public static <T extends Enum<T>> RuntimeException badValue(Enum<T> anEnum) { return Util.newInternal("Was not expecting value '" + anEnum + "' for enumeration '" + anEnum.getDeclaringClass().getName() + "' in this context"); }
From source file:org.apache.accumulo.core.client.mapreduce.lib.util.ConfiguratorBase.java
/** * Provides a configuration key for a given feature enum, prefixed by the implementingClass * /*from ww w . ja va2 s.c o m*/ * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param e * the enum used to provide the unique part of the configuration key * @return the configuration key * @since 1.5.0 */ protected static String enumToConfKey(Class<?> implementingClass, Enum<?> e) { return implementingClass.getSimpleName() + "." + e.getDeclaringClass().getSimpleName() + "." + StringUtils.camelize(e.name().toLowerCase()); }
From source file:org.apache.geode.internal.InternalDataSerializer.java
private static void writeGemFireEnum(Enum<?> e, DataOutput out) throws IOException { boolean isGemFireObject = isGemfireObject(e); DataSerializer.writePrimitiveByte(isGemFireObject ? GEMFIRE_ENUM : PDX_INLINE_ENUM, out); DataSerializer.writeString(e.getDeclaringClass().getName(), out); DataSerializer.writeString(e.name(), out); if (!isGemFireObject) { InternalDataSerializer.writeArrayLength(e.ordinal(), out); }//w w w.java 2 s . c om }
From source file:org.apache.hadoop.mapred.Counters.java
/** * Find the counter for the given enum. The same enum will always return the * same counter./*from w ww . j a va2 s .c om*/ * @param key the counter key * @return the matching counter object */ public synchronized Counter findCounter(Enum key) { Counter counter = cache.get(key); if (counter == null) { Group group = getGroup(key.getDeclaringClass().getName()); if (group != null) { counter = group.getCounterForName(key.toString()); if (counter != null) cache.put(key, counter); } } return counter; }
From source file:org.apache.hadoop.mapreduce.counters.AbstractCounters.java
/** * Find the counter for the given enum. The same enum will always return the * same counter./*from w w w. ja v a 2s.c o m*/ * @param key the counter key * @return the matching counter object */ public synchronized C findCounter(Enum<?> key) { C counter = cache.get(key); if (counter == null) { counter = findCounter(key.getDeclaringClass().getName(), key.name()); cache.put(key, counter); } return counter; }
From source file:org.apache.hive.spark.counter.SparkCounters.java
public void createCounter(Enum<?> key) { createCounter(key.getDeclaringClass().getName(), key.name()); }