com.h3c.util.codec

## Class EnumCodec<E extends Enum<E>>

- java.lang.Object
- - com.h3c.util.codec.EnumCodec<E>

- Type Parameters:
    `E` - enumeration class

      public class EnumCodec<E extends Enum<E>>
      extends Object

  This class provides the ability to encode and decode enumeration constants to a short string form. It uses a `StringSetCodec` behind the scenes to do the mapping, but provides methods in terms of the enumeration constants.
  See Also:
    `StringSetCodec`, `CodecFactory`

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `E` | `decode(String encoding)` Returns the enum constant mapped to the given encoding.
    `<T extends Enum<T>> String` | `encode(T constant)` Returns the encoding for the given constant.
    `int` | `size()` Returns the number of mappings in this codec, that is, the number of constants in the enumeration class.
    `String` | `toDebugString()` Returns a string representation of the codec, useful for debugging.

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

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

- - ### Method Detail

    - #### encode

          public <T extends Enum<T>> String encode(T constant)

      Returns the encoding for the given constant.
      Type Parameters:
        `T` - enumeration class
      Parameters:
        `constant` - the constant
      Returns:
        the encoding

    - #### decode

          public E decode(String encoding)

      Returns the enum constant mapped to the given encoding.
      Parameters:
        `encoding` - the encoding
      Returns:
        the corresponding enum constant

    - #### size

          public int size()

      Returns the number of mappings in this codec, that is, the number of constants in the enumeration class.
      Returns:
        the number of mappings

    - #### toDebugString

          public String toDebugString()

      Returns a string representation of the codec, useful for debugging.
      Returns:
        the debug string

Copyright © 2014. All Rights Reserved.