Class EnumTypeConverter
java.lang.Object
org.eclipse.persistence.mappings.converters.ObjectTypeConverter
org.eclipse.persistence.mappings.converters.EnumTypeConverter
- All Implemented Interfaces:
Serializable
,CoreConverter<DatabaseMapping,
,Session> org.eclipse.persistence.internal.descriptors.ClassNameConversionRequired
,Converter
Purpose: Object type converter is used to match a fixed number of
database data values to a Java enum object value. It can be used when the
values on the database and in the Java differ. To create an object type
converter, simply specify the set of conversion value pairs. A default value
and one-way conversion are also supported for legacy data situations.
- See Also:
- Author:
- Guy Pelletier
-
Field Summary
Fields inherited from class org.eclipse.persistence.mappings.converters.ObjectTypeConverter
addToAttributeOnlyConversionValueStrings, attributeToFieldValues, conversionValueStrings, converterName, dataType, dataTypeName, defaultAttributeValue, defaultAttributeValueString, fieldClassification, fieldClassificationName, fieldToAttributeValues, mapping, objectType, objectTypeName
-
Constructor Summary
ConstructorDescriptionEnumTypeConverter
(DatabaseMapping mapping, Class enumClass, boolean useOrdinalValues) PUBLIC: Creating an enum converter this way will create the conversion values for you using ordinal or name values.EnumTypeConverter
(DatabaseMapping mapping, String enumClassName) PUBLIC: Creating an enum converter this way expects that you will provide the conversion values separately.EnumTypeConverter
(DatabaseMapping mapping, String enumClassName, boolean useOrdinalValues) PUBLIC: Creating an enum converter this way will create the conversion values for you using ordinal or name values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
convertClassNamesToClasses
(ClassLoader classLoader) INTERNAL: Convert all the class-name-based settings in this converter to actual class-based settings.convertDataValueToObjectValue
(Object fieldValue, Session session) INTERNAL: Returns the corresponding attribute value for the specified field value.convertObjectValueToDataValue
(Object attributeValue, Session session) INTERNAL: Convert Enum object to the data value.protected void
initializeConversions
(Class enumClass) Methods inherited from class org.eclipse.persistence.mappings.converters.ObjectTypeConverter
addConversionValue, addConversionValueStrings, addToAttributeOnlyConversionValue, addToAttributeOnlyConversionValueStrings, getAttributeToFieldValues, getDefaultAttributeValue, getFieldClassification, getFieldClassification, getFieldClassificationName, getFieldToAttributeValueAssociations, getFieldToAttributeValues, getMapping, initialize, initializeFieldClassification, isMutable, loadClass, mapBooleans, mapGenders, mapResponses, setAttributeToFieldValues, setConverterName, setDataTypeName, setDefaultAttributeValue, setDefaultAttributeValueString, setFieldClassification, setFieldClassificationName, setFieldToAttributeValueAssociations, setFieldToAttributeValues, setMapping, setObjectTypeName, throwInitObjectException
-
Constructor Details
-
EnumTypeConverter
PUBLIC: Creating an enum converter this way will create the conversion values for you using ordinal or name values. -
EnumTypeConverter
PUBLIC: Creating an enum converter this way will create the conversion values for you using ordinal or name values. -
EnumTypeConverter
PUBLIC: Creating an enum converter this way expects that you will provide the conversion values separately.
-
-
Method Details
-
initializeConversions
-
getEnumClass
-
getEnumClassName
-
convertClassNamesToClasses
INTERNAL: Convert all the class-name-based settings in this converter to actual class-based settings. This method is used when converting a project that has been built with class names to a project with classes.- Specified by:
convertClassNamesToClasses
in interfaceorg.eclipse.persistence.internal.descriptors.ClassNameConversionRequired
- Overrides:
convertClassNamesToClasses
in classObjectTypeConverter
- Parameters:
classLoader
-
-
convertDataValueToObjectValue
INTERNAL: Returns the corresponding attribute value for the specified field value. Wraps the super method to return an Enum type from the string conversion.- Specified by:
convertDataValueToObjectValue
in interfaceConverter
- Specified by:
convertDataValueToObjectValue
in interfaceCoreConverter<DatabaseMapping,
Session> - Overrides:
convertDataValueToObjectValue
in classObjectTypeConverter
-
convertObjectValueToDataValue
INTERNAL: Convert Enum object to the data value. Internal enums are stored as strings (names) so this method wraps the super method in that if breaks down the enum to a string name before converting it.- Specified by:
convertObjectValueToDataValue
in interfaceConverter
- Specified by:
convertObjectValueToDataValue
in interfaceCoreConverter<DatabaseMapping,
Session> - Overrides:
convertObjectValueToDataValue
in classObjectTypeConverter
-