public final class EnumConverter extends Object implements org.apache.commons.beanutils.Converter
A specialized Converter
implementation dealing with all types of
enumeration classes.
The implementation of the convert(Class, Object)
method expects that
the passed in value is a constant as defined for an enumeration class as
string. It tries to find the corresponding instance of the enumeration class.
An instance of this class is registered per default as base class converter
at any new InvocationHelper
instance. Therefore conversions to
parameters or properties of Enum
types are supported out of the box.
Implementation note: This class has no state. So a single instance can be
shared between multiple instances. This instance can be obtained using the
getInstance()
factory method; creating new instances is now allowed.
Modifier and Type | Method and Description |
---|---|
Object |
convert(Class type,
Object value)
Performs the type conversion to an enumeration constant.
|
static EnumConverter |
getInstance()
Returns an instance of
EnumConverter . |
public static EnumConverter getInstance()
EnumConverter
. Use this factory method to
obtain a new instance rather than invoking a constructor.EnumConverter
instancepublic Object convert(Class type, Object value)
ConversionException
is thrown. There are multiple
reasons why this could happen, e.g. the value is not an exact string
representation of an enumeration constant, or the class might be no
Enum
class.convert
in interface org.apache.commons.beanutils.Converter
type
- the class to convert tovalue
- the object to be convertedCopyright © 2016 The JGUIraffe Team. All rights reserved.