Package de.xima.fc.converter.simple
Class EnumTransform<T extends Enum<T>>
- java.lang.Object
-
- de.xima.fc.converter.simple.EnumTransform<T>
-
- Type Parameters:
T
- Type of the enum class.
- All Implemented Interfaces:
org.simpleframework.xml.transform.Transform<T>
public class EnumTransform<T extends Enum<T>> extends Object implements org.simpleframework.xml.transform.Transform<T>
Transform
er similar to for enums which allows you to specify how unknown enum constants are handled.- Author:
- XIMA MEDIA GmbH
-
-
Constructor Summary
Constructors Constructor Description EnumTransform(Class<T> enumClass)
An enum transformer that uses thestrategyThrow()
strategy.EnumTransform(Class<T> enumClass, BiFunction<Class<T>,String,T> unknownEnumStrategy)
An enum transformer that uses the specified strategy for handling unknown enums.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description T
read(String value)
static <T extends Enum<T>>
BiFunction<Class<T>,String,T>strategyNull()
static <T extends Enum<T>>
BiFunction<Class<T>,String,T>strategyThrow()
String
write(T value)
-
-
-
Constructor Detail
-
EnumTransform
public EnumTransform(Class<T> enumClass)
An enum transformer that uses thestrategyThrow()
strategy.- Parameters:
enumClass
- Class of the enum type.
-
EnumTransform
public EnumTransform(Class<T> enumClass, BiFunction<Class<T>,String,T> unknownEnumStrategy)
An enum transformer that uses the specified strategy for handling unknown enums.- Parameters:
enumClass
- Class of the enum type.unknownEnumStrategy
- Strategy for resolving unknown enums. It is passed the enum class and the serialized string.
-
-
Method Detail
-
strategyNull
public static <T extends Enum<T>> BiFunction<Class<T>,String,T> strategyNull()
- Returns:
- A strategy that, if the enum constant does not exist, substitutes
null
.
-
strategyThrow
public static <T extends Enum<T>> BiFunction<Class<T>,String,T> strategyThrow()
- Returns:
- A strategy that, if the enum constant does not exist, throws an
IllegalArgumentException
.
-
-