Package org.apache.tapestry5.commons.util

## Class StringToEnumCoercion<T extends java.lang.Enum>

- java.lang.Object
- - org.apache.tapestry5.commons.util.StringToEnumCoercion<T>

- Type Parameters:
    `T` - the type of enumeration
  All Implemented Interfaces:
    `Coercion<java.lang.String,​T>`

      public final class StringToEnumCoercion<T extends java.lang.Enum>
      extends java.lang.Object
      implements Coercion<java.lang.String,​T>

  A `Coercion` for converting strings into an instance of a particular enumerated type. The `name` is used as the key to identify the enum instance, in a case-insensitive fashion. Moved from tapestry-core to tapestry-ioc in release 5.3, but kept in same package for compatibility. Moved tapestry-ioc to commons in release 5.4, but kept in same package for compatibility.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `StringToEnumCoercion​(java.lang.Class<T> enumClass)` |
    `StringToEnumCoercion​(java.lang.Class<T> enumClass, T... values)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `StringToEnumCoercion<T>` | `addAlias​(java.lang.String alias, T value)` | Allows an alias value (alternate) string to reference a value.
    `T` | `coerce​(java.lang.String input)` | Converts an input value.
    `static <T extends java.lang.Enum> StringToEnumCoercion<T>` | `create​(java.lang.Class<T> enumClass)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StringToEnumCoercion

          public StringToEnumCoercion​(java.lang.Class<T> enumClass)

    - #### StringToEnumCoercion

          public StringToEnumCoercion​(java.lang.Class<T> enumClass,
                                      T... values)

  - ### Method Detail

    - #### coerce

          public T coerce​(java.lang.String input)

      Description copied from interface: `Coercion`
      Converts an input value.
      Specified by:
        `coerce` in interface `Coercion<java.lang.String,​T extends java.lang.Enum>`
      Parameters:
        `input` - the input value

    - #### addAlias

          public StringToEnumCoercion<T> addAlias​(java.lang.String alias,
                                                  T value)

      Allows an alias value (alternate) string to reference a value.
      Since:
        5.2.2

    - #### create

          public static <T extends java.lang.Enum> StringToEnumCoercion<T> create​(java.lang.Class<T> enumClass)