net.sf.seaf.util.convert.simple
Class ConverterToEnum

java.lang.Object
  extended by net.sf.seaf.util.convert.simple.ConverterToEnum

public class ConverterToEnum
extends Object

Converter of any Object to Enum.


Constructor Summary
ConverterToEnum()
           
 
Method Summary
static
<E extends Enum<E>>
E
convert(Object o, Class<E> enumClass)
          Converts an Object to enum value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConverterToEnum

public ConverterToEnum()
Method Detail

convert

public static <E extends Enum<E>> E convert(Object o,
                                            Class<E> enumClass)
                                 throws IllegalArgumentException
Converts an Object to enum value.

Keeps null as null. Keeps enum value as passed in. Otherwise converts via String to an enum value of the given enum class.

Parameters:
o - Object to be converted
enumClass - Target enum class
Returns:
Enum value
Throws:
IllegalArgumentException - Thrown when the object cannot be converted to an instance of the enumeration provided


Copyright © 2008-2011 SEAF. All Rights Reserved.