Skip navigation links
org.eclipse.persistence.mappings.transformers
Class ConstantTransformer
java.lang.Object
org.eclipse.persistence.mappings.transformers.FieldTransformerAdapter
org.eclipse.persistence.mappings.transformers.ConstantTransformer
- All Implemented Interfaces:
- java.io.Serializable, 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:
org.eclipse.persistence.mappings.FieldTransformer
, Serialized Form
Field Summary |
protected java.lang.Object |
value
|
Method Summary |
java.lang.Object |
buildFieldValue(java.lang.Object object, java.lang.String fieldName, Session session)
INTERNAL: Always return the constant value. |
java.lang.Object |
getValue()
PUBLIC: Return the value of the constant. |
void |
setValue(java.lang.Object value)
PUBLIC: Set the value of the constant. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
value
protected java.lang.Object value
ConstantTransformer
public ConstantTransformer()
ConstantTransformer
public ConstantTransformer(java.lang.Object value)
- PUBLIC: Return a constant transformer for the constant value.
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:
buildFieldValue
in interface FieldTransformer
- Overrides:
buildFieldValue
in class FieldTransformerAdapter
-
- Parameters:
object
- - an instance of the domain class which contains the attribute
fieldName
- - 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
Skip navigation links