Tabnine Logo
Class.getEnumConstants
Code IndexAdd Tabnine to your IDE (free)

How to use
getEnumConstants
method
in
java.lang.Class

Best Java code snippets using java.lang.Class.getEnumConstants (Showing top 20 results out of 13,545)

origin: spring-projects/spring-framework

  @Override
  public T convert(Integer source) {
    return this.enumType.getEnumConstants()[source];
  }
}
origin: libgdx/libgdx

/** Returns the elements of this enum class or null if this Class object does not represent an enum type. */
static public Object[] getEnumConstants (Class c) {
  return c.getEnumConstants();
}
origin: libgdx/libgdx

/** Returns the elements of this enum class or null if this Class object does not represent an enum type. */
static public Object[] getEnumConstants (Class c) {
  return c.getEnumConstants();
}
origin: prestodb/presto

private EnumValues(Class<Enum<?>> enumClass, SerializableString[] textual)
{
  _enumClass = enumClass;
  _values = enumClass.getEnumConstants();
  _textual = textual;
}
origin: jenkinsci/jenkins

public Enum[] getEnumConstants() {
  return (Enum[])clazz.getEnumConstants();
}
origin: google/guava

/** Creates an empty {@code EnumMultiset}. */
private EnumMultiset(Class<E> type) {
 this.type = type;
 checkArgument(type.isEnum());
 this.enumConstants = type.getEnumConstants();
 this.counts = new int[enumConstants.length];
}
origin: org.apache.commons/commons-lang3

/**
 * <p>Gets the {@code List} of enums.</p>
 *
 * <p>This method is useful when you need a list of enums rather than an array.</p>
 *
 * @param <E> the type of the enumeration
 * @param enumClass  the class of the enum to query, not null
 * @return the modifiable list of enums, never null
 */
public static <E extends Enum<E>> List<E> getEnumList(final Class<E> enumClass) {
  return new ArrayList<>(Arrays.asList(enumClass.getEnumConstants()));
}
origin: google/guava

private EnumHashBiMap(Class<K> keyType) {
 super(
   WellBehavedMap.wrap(new EnumMap<K, V>(keyType)),
   Maps.<V, K>newHashMapWithExpectedSize(keyType.getEnumConstants().length));
 this.keyType = keyType;
}
origin: google/guava

 /**
  * Returns the ClassValue-using validator, or falls back to the "weak Set" implementation if
  * unable to do so.
  */
 static GetCheckedTypeValidator getBestValidator() {
  try {
   Class<?> theClass = Class.forName(CLASS_VALUE_VALIDATOR_NAME);
   return (GetCheckedTypeValidator) theClass.getEnumConstants()[0];
  } catch (Throwable t) { // ensure we really catch *everything*
   return weakSetValidator();
  }
 }
}
origin: google/guava

 /**
  * Returns the Unsafe-using Comparator, or falls back to the pure-Java implementation if unable
  * to do so.
  */
 static Comparator<byte[]> getBestComparator() {
  try {
   Class<?> theClass = Class.forName(UNSAFE_COMPARATOR_NAME);
   // yes, UnsafeComparator does implement Comparator<byte[]>
   @SuppressWarnings("unchecked")
   Comparator<byte[]> comparator = (Comparator<byte[]>) theClass.getEnumConstants()[0];
   return comparator;
  } catch (Throwable t) { // ensure we really catch *everything*
   return lexicographicalComparatorJavaImpl();
  }
 }
}
origin: eclipse-vertx/vert.x

/**
 * Sets the list of values accepted by this option from the option's type.
 */
private void setChoicesFromEnumType() {
 Object[] constants = type.getEnumConstants();
 for (Object c : constants) {
  addChoice(c.toString());
 }
}
origin: prestodb/presto

/** Creates an empty {@code EnumMultiset}. */
private EnumMultiset(Class<E> type) {
 this.type = type;
 checkArgument(type.isEnum());
 this.enumConstants = type.getEnumConstants();
 this.counts = new int[enumConstants.length];
}
origin: google/guava

/**
 * @serialData the {@code Class<E>} for the enum type, the number of distinct elements, the first
 *     element, its count, the second element, its count, and so on
 */
@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 @SuppressWarnings("unchecked") // reading data stored by writeObject
 Class<E> localType = (Class<E>) stream.readObject();
 type = localType;
 enumConstants = type.getEnumConstants();
 counts = new int[enumConstants.length];
 Serialization.populateMultiset(this, stream);
}
origin: google/guava

@SuppressWarnings("unchecked") // reading field populated by writeObject
@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 keyType = (Class<K>) stream.readObject();
 setDelegates(
   WellBehavedMap.wrap(new EnumMap<K, V>(keyType)),
   new HashMap<V, K>(keyType.getEnumConstants().length * 3 / 2));
 Serialization.populateMap(this, stream);
}
origin: spring-projects/spring-framework

/**
 * Render the inner '{@code option}' tags using the {@link #optionSource}.
 * @see #doRenderFromCollection(java.util.Collection, TagWriter)
 */
private void renderFromEnum(TagWriter tagWriter) throws JspException {
  doRenderFromCollection(CollectionUtils.arrayToList(((Class<?>) this.optionSource).getEnumConstants()), tagWriter);
}
origin: prestodb/presto

private EnumHashBiMap(Class<K> keyType) {
 super(
   WellBehavedMap.wrap(new EnumMap<K, V>(keyType)),
   Maps.<V, K>newHashMapWithExpectedSize(keyType.getEnumConstants().length));
 this.keyType = keyType;
}
origin: prestodb/presto

@SuppressWarnings("unchecked") // reading field populated by writeObject
@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 keyType = (Class<K>) stream.readObject();
 setDelegates(
   WellBehavedMap.wrap(new EnumMap<K, V>(keyType)),
   new HashMap<V, K>(keyType.getEnumConstants().length * 3 / 2));
 Serialization.populateMap(this, stream);
}
origin: spring-projects/spring-framework

  public T convert(String source) {
    for (T value : enumType.getEnumConstants()) {
      if (value.getBaseCode().equals(source)) {
        return value;
      }
    }
    return null;
  }
}
origin: spring-projects/spring-framework

  public T convert(String source) {
    for (T value : enumType.getEnumConstants()) {
      if (value.getCode().equals(source)) {
        return value;
      }
    }
    return null;
  }
}
origin: google/guava

@GwtIncompatible // weak references
private WeakReference<?> doTestClassUnloading() throws Exception {
 URLClassLoader shadowLoader = new URLClassLoader(getClassPathUrls(), null);
 @SuppressWarnings("unchecked")
 Class<TestEnum> shadowTestEnum =
   (Class<TestEnum>) Class.forName(TestEnum.class.getName(), false, shadowLoader);
 assertNotSame(shadowTestEnum, TestEnum.class);
 // We can't write Set<TestEnum> because that is a Set of the TestEnum from the original
 // ClassLoader.
 Set<Object> shadowConstants = new HashSet<>();
 for (TestEnum constant : TestEnum.values()) {
  Optional<TestEnum> result = Enums.getIfPresent(shadowTestEnum, constant.name());
  assertThat(result).isPresent();
  shadowConstants.add(result.get());
 }
 assertEquals(ImmutableSet.<Object>copyOf(shadowTestEnum.getEnumConstants()), shadowConstants);
 Optional<TestEnum> result = Enums.getIfPresent(shadowTestEnum, "blibby");
 assertThat(result).isAbsent();
 return new WeakReference<>(shadowLoader);
}
java.langClassgetEnumConstants

Javadoc

Returns the enum constants associated with this Class. Returns null if this Class does not represent an enum type.

Popular methods of Class

  • getName
    Returns the name of the class represented by this Class. For a description of the format which is us
  • getSimpleName
  • getClassLoader
  • isAssignableFrom
    Determines if the class or interface represented by this Class object is either the same as, or is a
  • forName
    Returns the Class object associated with the class or interface with the given string name, using th
  • newInstance
    Returns a new instance of the class represented by this Class, created by invoking the default (that
  • getMethod
    Returns a Method object that reflects the specified public member method of the class or interface r
  • getResourceAsStream
  • getSuperclass
    Returns the Class representing the superclass of the entity (class, interface, primitive type or voi
  • getConstructor
  • cast
    Casts an object to the class or interface represented by this Class object.
  • isInstance
  • cast,
  • isInstance,
  • getCanonicalName,
  • getDeclaredField,
  • isArray,
  • getAnnotation,
  • getDeclaredFields,
  • getResource,
  • getDeclaredMethod,
  • getMethods

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • JFileChooser (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now