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
ConstructorsConstructorDescriptionEnumTransform
(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
Modifier and TypeMethodDescriptionstatic <T extends Enum<T>>
BiFunction<Class<T>,String, T> static <T extends Enum<T>>
BiFunction<Class<T>,String, T>
-
Constructor Details
-
EnumTransform
An enum transformer that uses thestrategyThrow()
strategy.- Parameters:
enumClass
- Class of the enum type.
-
EnumTransform
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 Details
-
read
-
write
-
strategyNull
- Returns:
- A strategy that, if the enum constant does not exist, substitutes
null
.
-
strategyThrow
- Returns:
- A strategy that, if the enum constant does not exist, throws an
IllegalArgumentException
.
-