org.apache.tapestry5.util

## Class EnumValueEncoder<E extends Enum<E>>

- java.lang.Object
- - org.apache.tapestry5.util.EnumValueEncoder<E>

- All Implemented Interfaces:
    ValueEncoder<E>

      public class EnumValueEncoder<E extends Enum<E>>
      extends Object
      implements ValueEncoder<E>

  A value encoder that can be used for arbitrary Enum types. The enum name is stored as the client side value.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EnumValueEncoder(TypeCoercer typeCoercer, Class<E> enumType)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `toClient(E value)` Converts a value into a client-side representation.
    `E` | `toValue(String clientValue)` Converts a client-side representation, provided by `ValueEncoder.toClient(Object)`, back into a server-side value.

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

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

- - ### Constructor Detail

    - #### EnumValueEncoder

          public EnumValueEncoder(TypeCoercer typeCoercer,
                                  Class<E> enumType)

  - ### Method Detail

    - #### toClient

          public String toClient(E value)

      Description copied from interface: `ValueEncoder`
      Converts a value into a client-side representation. The value should be parseable by `ValueEncoder.toValue(String)`. In some cases, what is returned is an identifier used to locate the true object, rather than a string representation of the value itself.
      Specified by:
        `toClient` in interface `ValueEncoder<E extends Enum<E>>`
      Parameters:
        `value` - to be encoded
      Returns:
        a string representation of the value, or the value's identity

    - #### toValue

          public E toValue(String clientValue)

      Description copied from interface: `ValueEncoder`
      Converts a client-side representation, provided by `ValueEncoder.toClient(Object)`, back into a server-side value.
      Specified by:
        `toValue` in interface `ValueEncoder<E extends Enum<E>>`
      Parameters:
        `clientValue` - string representation of the value's identity
      Returns:
        the corresponding entity, or null if not found

5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.