org.apache.tapestry5.util
Class StringToEnumCoercion<T extends Enum>

java.lang.Object
  extended by org.apache.tapestry5.util.StringToEnumCoercion<T>
Type Parameters:
T - the type of enumeration
All Implemented Interfaces:
Coercion<String,T>

public final class StringToEnumCoercion<T extends Enum>
extends Object
implements Coercion<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.


Constructor Summary
StringToEnumCoercion(Class<T> enumClass)
           
StringToEnumCoercion(Class<T> enumClass, T... values)
           
 
Method Summary
 T coerce(String input)
          Converts an input value.
static
<T extends Enum>
StringToEnumCoercion<T>
create(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(Class<T> enumClass)

StringToEnumCoercion

public StringToEnumCoercion(Class<T> enumClass,
                            T... values)
Method Detail

coerce

public T coerce(String input)
Description copied from interface: Coercion
Converts an input value.

Specified by:
coerce in interface Coercion<String,T extends Enum>
Parameters:
input - the input value

create

public static <T extends Enum> StringToEnumCoercion<T> create(Class<T> enumClass)


Copyright © 2006-2009 Apache Software Foundation. All Rights Reserved.