List of usage examples for java.lang Enum getDeclaringClass
@SuppressWarnings("unchecked") public final Class<E> getDeclaringClass()
From source file:org.apache.hive.spark.counter.SparkCounters.java
public void increment(Enum<?> key, long incrValue) { increment(key.getDeclaringClass().getName(), key.name(), incrValue); }
From source file:org.apache.hive.spark.counter.SparkCounters.java
public SparkCounter getCounter(Enum<?> key) { return getCounter(key.getDeclaringClass().getName(), key.name()); }
From source file:org.carrot2.util.simplexml.SimpleXmlWrapperValue.java
/** * Wraps the provided value with the serialization wrapper. *//*from ww w. j ava 2 s .c om*/ static SimpleXmlWrapperValue wrap(Object value) { final SimpleXmlWrapperValue wrapper = new SimpleXmlWrapperValue(); if (value == null) { return wrapper; } final Class<?> valueType = value.getClass(); if (TO_STRING_VALUE_OF_TYPES.contains(valueType)) { wrapper.value = value.toString(); wrapper.type = valueType.getName(); } else if (value instanceof Character) { wrapper.value = value.toString(); wrapper.type = Character.class.getName(); } else if (value instanceof String) { wrapper.value = (String) value; wrapper.type = null; } else if (Class.class.isInstance(value)) { wrapper.value = ((Class<?>) value).getName(); wrapper.type = Class.class.getName(); } else if (value instanceof Enum<?>) { final Enum<?> e = (Enum<?>) value; wrapper.value = e.name(); wrapper.type = e.getDeclaringClass().getName(); } else if (value.getClass().getAnnotation(Root.class) != null) { wrapper.wrapper = value; } else { // Try to get a wrapper. wrapper.wrapper = SimpleXmlWrapperValue.wrapCustom(value); } return wrapper; }
From source file:org.datalorax.populace.core.populate.mutator.change.ChangeEnumMutator.java
private Object changeEnum(final Enum currentValue) { final Object[] allValues = currentValue.getDeclaringClass().getEnumConstants(); final int newOrdinal = (currentValue.ordinal() + 1) % allValues.length; return allValues[newOrdinal]; }
From source file:org.jboss.forge.roaster.model.impl.AnnotationImpl.java
@Override public AnnotationSource<O> setEnumArrayValue(String name, final Enum<?>... values) { final List<String> literals = new ArrayList<>(); for (Enum<?> value : requireNonNull(values)) { Import imprt = getOrigin().addImport(requireNonNull(value).getDeclaringClass()); if (imprt == null) { literals.add(value.getDeclaringClass().getCanonicalName() + "." + value.name()); } else {//from ww w .j av a2 s .c o m literals.add(value.getDeclaringClass().getSimpleName() + "." + value.name()); } } return setArrayLiteralValue(name, literals); }