Class ConstantTransformer
- java.lang.Object
-
- org.eclipse.persistence.mappings.transformers.FieldTransformerAdapter
-
- org.eclipse.persistence.mappings.transformers.ConstantTransformer
-
- All Implemented Interfaces:
Serializable
,CoreFieldTransformer<Session>
,FieldTransformer
public class ConstantTransformer extends FieldTransformerAdapter
Purpose: Allows a field to always be mapped to a constant value. This allows default values to be provided for un-mapped fields.
- See Also:
FieldTransformer
, Serialized Form- Author:
- James Sutherland
- Since:
- 10.1.3
-
-
Field Summary
Fields Modifier and Type Field Description protected Object
value
-
Fields inherited from interface org.eclipse.persistence.core.mappings.transformers.CoreFieldTransformer
BUILD_FIELD_VALUE_METHOD
-
-
Constructor Summary
Constructors Constructor Description ConstantTransformer()
ConstantTransformer(Object value)
PUBLIC: Return a constant transformer for the constant value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
buildFieldValue(Object object, String fieldName, Session session)
INTERNAL: Always return the constant value.Object
getValue()
PUBLIC: Return the value of the constant.void
setValue(Object value)
PUBLIC: Set the value of the constant.-
Methods inherited from class org.eclipse.persistence.mappings.transformers.FieldTransformerAdapter
initialize
-
-
-
-
Field Detail
-
value
protected Object value
-
-
Constructor Detail
-
ConstantTransformer
public ConstantTransformer()
-
ConstantTransformer
public ConstantTransformer(Object value)
PUBLIC: Return a constant transformer for the constant value.
-
-
Method Detail
-
getValue
public Object getValue()
PUBLIC: Return the value of the constant.
-
setValue
public void setValue(Object value)
PUBLIC: Set the value of the constant.
-
buildFieldValue
public Object buildFieldValue(Object object, String fieldName, Session session)
INTERNAL: Always return the constant value.- Specified by:
buildFieldValue
in interfaceCoreFieldTransformer<Session>
- Specified by:
buildFieldValue
in interfaceFieldTransformer
- Overrides:
buildFieldValue
in classFieldTransformerAdapter
- Parameters:
object
- - an instance of the domain class which contains the attributefieldName
- - the name of the field being transformed. Used if the user wants to use this transformer for multiple fields.session
- - the current session- Returns:
- - The value to be written for the field associated with this transformer
-
-