Top Description Fields Constructors Methods
org.eclipse.persistence.mappings.transformers

public Class ConstantTransformer

extends FieldTransformerAdapter
Class Inheritance
Imports
org.eclipse.persistence.sessions.Session

Purpose: Allows a field to always be mapped to a constant value. This allows default values to be provided for un-mapped fields.

Author
James Sutherland
Since
10.1.3
See Also
FieldTransformer

Field Summary

Modifier and TypeField and Description
protected Object

Constructor Summary

AccessConstructor and Description
public
public
ConstantTransformer(Object value)

PUBLIC: Return a constant transformer for the constant value.

Method Summary

Modifier and TypeMethod and Description
public Object
buildFieldValue(Object
- an instance of the domain class which contains the attribute
object
,
String
- the name of the field being transformed. Used if the user wants to use this transformer for multiple fields.
fieldName
,
Session
- the current session
session
)

Overrides org.eclipse.persistence.mappings.transformers.FieldTransformerAdapter.buildFieldValue.

Implements org.eclipse.persistence.mappings.transformers.FieldTransformer.buildFieldValue.

INTERNAL: Always return the constant value.
public Object
getValue()

PUBLIC: Return the value of the constant.

public void
setValue(Object value)

PUBLIC: Set the value of the constant.

Inherited from org.eclipse.persistence.mappings.transformers.FieldTransformerAdapter:
initialize

Field Detail

valueback to summary
protected Object value

Constructor Detail

ConstantTransformerback to summary
public ConstantTransformer()
ConstantTransformerback to summary
public ConstantTransformer(Object value)

PUBLIC: Return a constant transformer for the constant value.

Method Detail

buildFieldValueback to summary
public Object buildFieldValue(Object object, String fieldName, Session session)

Overrides org.eclipse.persistence.mappings.transformers.FieldTransformerAdapter.buildFieldValue.

Implements org.eclipse.persistence.mappings.transformers.FieldTransformer.buildFieldValue.

INTERNAL: Always return the constant value.

Parameters
object:Object

Doc from org.eclipse.persistence.mappings.transformers.FieldTransformer.buildFieldValue.

- an instance of the domain class which contains the attribute

fieldName:String

Doc from org.eclipse.persistence.mappings.transformers.FieldTransformer.buildFieldValue.

- the name of the field being transformed. Used if the user wants to use this transformer for multiple fields.

session:Session

Doc from org.eclipse.persistence.mappings.transformers.FieldTransformer.buildFieldValue.

- the current session

Returns:Object

Doc from org.eclipse.persistence.mappings.transformers.FieldTransformer.buildFieldValue.

- The value to be written for the field associated with this transformer

Annotations
@Override
getValueback to summary
public Object getValue()

PUBLIC: Return the value of the constant.

setValueback to summary
public void setValue(Object value)

PUBLIC: Set the value of the constant.