Package cz.cvut.kbss.jopa.oom.converter
Class StringEnumConverter<E extends Enum<E>>
java.lang.Object
cz.cvut.kbss.jopa.oom.converter.StringEnumConverter<E>
- Type Parameters:
E
- Enum type
- All Implemented Interfaces:
AttributeConverter<E,
,Object> ConverterWrapper<E,
Object>
public class StringEnumConverter<E extends Enum<E>>
extends Object
implements ConverterWrapper<E,Object>
Built-in converter for mapping to/from enum-valued attributes.
Uses the default Enum.valueOf(Class, String)
method to transform string-based value loaded from repository to
the appropriate attribute type. In the opposite direction, enum value is converted to String
. It is used for
enumerated attributes with EnumType.ORDINAL
configuration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToAttribute
(Object value) Converts the data stored in the repository into the value to be stored in the entity attribute.convertToAxiomValue
(E value) Converts the value stored in the entity attribute into the data representation to be stored in the repository and supported by the OntoDriver API.boolean
supportsAxiomValueType
(Class<?> type) Checks whether the wrapped converter supports converting the specified axiom value type.
-
Constructor Details
-
StringEnumConverter
-
-
Method Details
-
supportsAxiomValueType
Description copied from interface:ConverterWrapper
Checks whether the wrapped converter supports converting the specified axiom value type.- Specified by:
supportsAxiomValueType
in interfaceConverterWrapper<E extends Enum<E>,
Object> - Parameters:
type
- Axiom value type- Returns:
- Whether the type is supported by this wrapper
-
convertToAxiomValue
Description copied from interface:AttributeConverter
Converts the value stored in the entity attribute into the data representation to be stored in the repository and supported by the OntoDriver API.- Specified by:
convertToAxiomValue
in interfaceAttributeConverter<E extends Enum<E>,
Object> - Parameters:
value
- Value to convert- Returns:
- Converted data
-
convertToAttribute
Description copied from interface:AttributeConverter
Converts the data stored in the repository into the value to be stored in the entity attribute.Note that it is the responsibility of the converter writer to specify the correct
value
type for the corresponding value for use by the OntoDriver: i.e., persistence providers are not expected to do such type conversion.- Specified by:
convertToAttribute
in interfaceAttributeConverter<E extends Enum<E>,
Object> - Parameters:
value
- Value to convert- Returns:
- Converted data
-