Class EnumConverter<T extends Enum<T>>

All Implemented Interfaces:
Converter<String,T>, StringConverter<T>, TwoWayConverter<String,T>, Broadcaster, Listener, Repeater, Transceiver, Receiver, Transmitter, NamedObject, StringMapper<T>

public class EnumConverter<T extends Enum<T>> extends BaseStringConverter<T>
Converts between strings and enum values. Lower case hyphenated values are accepted. For example, the enum value max-value is equivalent to MAX_VALUE.
Author:
jonathanl (shibo)
  • Constructor Details

    • EnumConverter

      public EnumConverter(Listener listener, Class<T> enumType)
      Parameters:
      listener - The listener to hear any conversion issues
      enumType - The enum type to convert
  • Method Details

    • onToValue

      protected T onToValue(String value)
      Implemented by subclass to convert the given string to a value. The subclass implementation will never be called in cases where value is null or empty, so it need not check for either case.
      Overrides:
      onToValue in class BaseStringConverter<T extends Enum<T>>
      Parameters:
      value - The (guaranteed non-null, non-empty) value to convert
      Returns:
      The converted object