Class EnumColumn<T extends Enum<T>>

java.lang.Object
org.refcodes.tabular.AbstractColumn<T>
org.refcodes.tabular.EnumColumn<T>
All Implemented Interfaces:
Cloneable, org.refcodes.mixin.KeyAccessor<String>, org.refcodes.mixin.TypeAccessor<T>, Column<T>

public class EnumColumn<T extends Enum<T>> extends AbstractColumn<T> implements Cloneable
Implementation of the Column interface for working with Enum instances, being Cloneable.
  • Constructor Details

  • Method Details

    • toStorageStrings

      public String[] toStorageStrings(T aValue)
      A Column implementation can provide its own text exchange format for the given objects. This method enables the Column to convert a value of the given type to a String array and via Column.fromStorageStrings(String[]) back to the value (bijective). This method supports data sinks (such as Amazon's SimpleDb) which provide dedicated support for multiple values in a row's entry: In case T is an array type, then the storage String representations of the elements in that array may be placed in dedicated entries of the returned String array. In case T is not an array type then the returned String array may contain just one value. In case data sinks (such as relational databases) are to be addressed which allow only a single value in a row's entry, then the method Column.toStorageString(Object) may be used instead. In case the enumeration implements the AliasAccessor interface, then the according alias is the preferred storage string to be used.
      Specified by:
      toStorageStrings in interface Column<T extends Enum<T>>
      Parameters:
      aValue - the element to be converted to a String array.
      Returns:
      The String array representation of the value.
    • fromStorageStrings

      public T fromStorageStrings(String[] aStringValues) throws ParseException
      A Column implementation can provide its own text exchange format for the given objects. This method enables the Column to convert a String array value to a value of the given type and via Column.toStorageStrings(Object) back to the String array (bijective). This method supports data sinks (such as Amazon's SimpleDb) which provide dedicated support for multiple values in a row's entry: In case T is an array type, then the storage String representations of the elements in that array may be placed in dedicated entries of the provided String array. In case T is not an array type then the passed String array may contain just one value. In case data sinks (such as relational databases) are to be addressed which allow only a single value in a row's entry, then the method Column.fromStorageString(String) may be used instead. If possible, the enumeration's name is used for resolving the value. In case the enumeration implements the AliasAccessor interface, then also the according alias is used for resolving the value. If both fails, the the storage string is interpreted as index pointing into the enumeration's values.
      Specified by:
      fromStorageStrings in interface Column<T extends Enum<T>>
      Parameters:
      aStringValues - The value to be converted to a type instance.
      Returns:
      The type representation of the value.
      Throws:
      ParseException - in case parsing the String was not possible
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class AbstractColumn<T extends Enum<T>>
      Throws:
      CloneNotSupportedException