Module org.eclipse.persistence.core
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.
- Since:
- 10.1.3
- Author:
- James Sutherland
- See Also:
FieldTransformer, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Objectvalue-
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 ObjectbuildFieldValue(Object object, String fieldName, Session session)INTERNAL: Always return the constant value.ObjectgetValue()PUBLIC: Return the value of the constant.voidsetValue(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:
buildFieldValuein interfaceCoreFieldTransformer<Session>- Specified by:
buildFieldValuein interfaceFieldTransformer- Overrides:
buildFieldValuein 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
-
-