Class Enums

java.lang.Object
com.google.common.base.Enums

@GwtCompatible(emulated=true) @Beta @Deprecated(since="2022-12-01") public final class Enums extends Object
Deprecated.
The Google Guava Core Libraries are deprecated and will not be part of the AEM SDK after April 2023
Utility methods for working with Enum instances.
Since:
9.0
  • Method Details

    • getField

      @GwtIncompatible("reflection") public static Field getField(Enum<?> enumValue)
      Deprecated.
      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
    • valueOfFunction

      public static <T extends Enum<T>> Function<String,T> valueOfFunction(Class<T> enumClass)
      Deprecated.
      Returns a Function that maps an Enum name to the associated Enum constant. The Function will return null if the Enum constant does not exist.
      Parameters:
      enumClass - the Class of the Enum declaring the constant values.
    • getIfPresent

      public static <T extends Enum<T>> Optional<T> getIfPresent(Class<T> enumClass, String value)
      Deprecated.
      Returns an optional enum constant for the given type, using Enum.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