MCPcopy Create free account
hub / github.com/antlr/codebuff / getField

Method getField

corpus/java/training/guava/base/Enums.java:53–61  ·  view source on GitHub ↗

Returns the Field in which enumValue is defined. For example, to get the Description annotation on the GOLF constant of enum Sport, use Enums.getField(Sport.GOLF).getAnnotation(Description.class). @since 12.0

(Enum<?> enumValue)

Source from the content-addressed store, hash-verified

51 * @since 12.0
52 */
53 @GwtIncompatible // reflection
54 public static Field getField(Enum<?> enumValue) {
55 Class<?> clazz = enumValue.getDeclaringClass();
56 try {
57 return clazz.getDeclaredField(enumValue.name());
58 } catch (NoSuchFieldException impossible) {
59 throw new AssertionError(impossible);
60 }
61 }
62
63 /**
64 * Returns an optional enum constant for the given type, using {@link Enum#valueOf}. If the

Callers 2

tryGetFieldMethod · 0.45
handleArgsMethod · 0.45

Calls 1

getDeclaringClassMethod · 0.45

Tested by

no test coverage detected