Class AbstractCpoData

java.lang.Object
org.synchronoss.cpo.core.AbstractCpoData
All Implemented Interfaces:
CpoData
Direct Known Subclasses:
AbstractBindableCpoData

public abstract class AbstractCpoData extends Object implements CpoData
Base CpoData implementation that owns the CpoAttribute being bound and handles the transform half of the contract (transformIn(Object)/transformOut(Object)). Datastore-specific subclasses supply the actual reflective getter/setter invocation.
Author:
dberry
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance bound to the given attribute.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the attribute this instance moves data for.
    Gets the type that the datastore-side value should be coerced to before being handed to the bean's setter: the setter's own parameter type, or the transform's input type if the attribute has a configured CpoTransform.
    Gets the type that the bean attribute's value is coerced to before being bound to the datastore: the getter's own return type, or the transform's output type if the attribute has a configured CpoTransform.
    Invokes the bean's getter for the bound attribute.
    void
    invokeSetter(Object instanceObject)
    Invokes the bean's setter for the bound attribute.
    void
    Sets the attribute this instance moves data for.
    transformIn(Object datasourceObject)
    Transforms a value read from the datastore into the form expected by the bean attribute, applying the attribute's configured transform (if any).
    transformOut(Object attributeObject)
    Transforms a value read from the bean attribute into the form expected by the datastore, applying the attribute's configured transform (if any).

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractCpoData

      public AbstractCpoData(CpoAttribute cpoAttribute)
      Creates an instance bound to the given attribute.
      Parameters:
      cpoAttribute - the attribute this instance moves data for
  • Method Details

    • getCpoAttribute

      public CpoAttribute getCpoAttribute()
      Gets the attribute this instance moves data for.
      Returns:
      the bound attribute
    • setCpoAttribute

      public void setCpoAttribute(CpoAttribute cpoAttribute)
      Sets the attribute this instance moves data for.
      Parameters:
      cpoAttribute - the attribute to bind
    • transformIn

      public Object transformIn(Object datasourceObject) throws CpoException
      Transforms a value read from the datastore into the form expected by the bean attribute, applying the attribute's configured transform (if any).

      Applies the attribute's configured CpoTransform, if any; otherwise returns the value unchanged.

      Specified by:
      transformIn in interface CpoData
      Parameters:
      datasourceObject - the raw value read from the datastore
      Returns:
      the value to pass to the bean's setter, transformed if a transform is configured
      Throws:
      CpoException - if the transform fails
    • transformOut

      public Object transformOut(Object attributeObject) throws CpoException
      Transforms a value read from the bean attribute into the form expected by the datastore, applying the attribute's configured transform (if any).

      Applies the attribute's configured CpoTransform, if any; otherwise returns the value unchanged.

      Specified by:
      transformOut in interface CpoData
      Parameters:
      attributeObject - the raw value read from the bean's getter
      Returns:
      the value to bind to the datastore statement, transformed if a transform is configured
      Throws:
      CpoException - if the transform fails
    • invokeGetter

      public Object invokeGetter() throws CpoException
      Invokes the bean's getter for the bound attribute.

      Not implemented by this base class; subclasses that support reflective getter invocation must override this method.

      Specified by:
      invokeGetter in interface CpoData
      Returns:
      the value returned by the attribute's getter
      Throws:
      UnsupportedOperationException - always, unless overridden by a subclass
      CpoException - if the getter cannot be invoked
    • invokeSetter

      public void invokeSetter(Object instanceObject) throws CpoException
      Invokes the bean's setter for the bound attribute.

      Not implemented by this base class; subclasses that support reflective setter invocation must override this method.

      Specified by:
      invokeSetter in interface CpoData
      Parameters:
      instanceObject - the value to pass to the attribute's setter
      Throws:
      UnsupportedOperationException - always, unless overridden by a subclass
      CpoException - if the setter cannot be invoked
    • getDataGetterReturnType

      public Class<?> getDataGetterReturnType()
      Gets the type that the datastore-side value should be coerced to before being handed to the bean's setter: the setter's own parameter type, or the transform's input type if the attribute has a configured CpoTransform.
      Returns:
      the expected type of the raw datastore value
    • getDataSetterParamType

      public Class<?> getDataSetterParamType()
      Gets the type that the bean attribute's value is coerced to before being bound to the datastore: the getter's own return type, or the transform's output type if the attribute has a configured CpoTransform.
      Returns:
      the expected type of the value to bind to the datastore