Class ConstantTransformer
- java.lang.Object
-
- org.eclipse.persistence.mappings.transformers.FieldTransformerAdapter
-
- org.eclipse.persistence.mappings.transformers.ConstantTransformer
-
- All Implemented Interfaces:
java.io.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 java.lang.Objectvalue-
Fields inherited from interface org.eclipse.persistence.core.mappings.transformers.CoreFieldTransformer
BUILD_FIELD_VALUE_METHOD
-
-
Constructor Summary
Constructors Constructor Description ConstantTransformer()ConstantTransformer(java.lang.Object value)PUBLIC: Return a constant transformer for the constant value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectbuildFieldValue(java.lang.Object object, java.lang.String fieldName, Session session)INTERNAL: Always return the constant value.java.lang.ObjectgetValue()PUBLIC: Return the value of the constant.voidsetValue(java.lang.Object value)PUBLIC: Set the value of the constant.-
Methods inherited from class org.eclipse.persistence.mappings.transformers.FieldTransformerAdapter
initialize
-
-
-
-
Method Detail
-
getValue
public java.lang.Object getValue()
PUBLIC: Return the value of the constant.
-
setValue
public void setValue(java.lang.Object value)
PUBLIC: Set the value of the constant.
-
buildFieldValue
public java.lang.Object buildFieldValue(java.lang.Object object, java.lang.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
-
-