Package com.google.common.base
Class Enums
- java.lang.Object
-
- com.google.common.base.Enums
-
@GwtCompatible(emulated=true) @Beta @Deprecated(since="2022-12-01") public final class Enums extends java.lang.Object
Deprecated.The Google Guava Core Libraries are deprecated and will not be part of the AEM SDK after April 2023Utility methods for working withEnum
instances.- Since:
- 9.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.reflect.Field
getField(java.lang.Enum<?> enumValue)
Deprecated.Returns theField
in whichenumValue
is defined.static <T extends java.lang.Enum<T>>
Optional<T>getIfPresent(java.lang.Class<T> enumClass, java.lang.String value)
Deprecated.Returns an optional enum constant for the given type, usingEnum.valueOf(java.lang.Class<T>, java.lang.String)
.static <T extends java.lang.Enum<T>>
Function<java.lang.String,T>valueOfFunction(java.lang.Class<T> enumClass)
Deprecated.
-
-
-
Method Detail
-
getField
@GwtIncompatible("reflection") public static java.lang.reflect.Field getField(java.lang.Enum<?> enumValue)
Deprecated.Returns theField
in whichenumValue
is defined. For example, to get theDescription
annotation on theGOLF
constant of enumSport
, useEnums.getField(Sport.GOLF).getAnnotation(Description.class)
.- Since:
- 12.0
-
valueOfFunction
public static <T extends java.lang.Enum<T>> Function<java.lang.String,T> valueOfFunction(java.lang.Class<T> enumClass)
Deprecated.Returns aFunction
that maps anEnum
name to the associatedEnum
constant. TheFunction
will returnnull
if theEnum
constant does not exist.- Parameters:
enumClass
- theClass
of theEnum
declaring the constant values.
-
getIfPresent
public static <T extends java.lang.Enum<T>> Optional<T> getIfPresent(java.lang.Class<T> enumClass, java.lang.String value)
Deprecated.Returns an optional enum constant for the given type, usingEnum.valueOf(java.lang.Class<T>, java.lang.String)
. If the constant does not exist,Optional.absent()
is returned. A common use case is for parsing user input or falling back to a default enum constant. For example,Enums.getIfPresent(Country.class, countryInput).or(Country.DEFAULT);
- Since:
- 12.0
-
-