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:
Author:
James Sutherland
  • Field Details

    • value

      protected Object value
  • Constructor Details

    • ConstantTransformer

      public ConstantTransformer()
    • ConstantTransformer

      public ConstantTransformer(Object value)
      PUBLIC: Return a constant transformer for the constant value.
  • Method Details

    • 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 interface CoreFieldTransformer<Session>
      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