Package org.synchronoss.cpo.core
Class AbstractCpoData
java.lang.Object
org.synchronoss.cpo.core.AbstractCpoData
- All Implemented Interfaces:
CpoData
- Direct Known Subclasses:
AbstractBindableCpoData
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
ConstructorsConstructorDescriptionAbstractCpoData(CpoAttribute cpoAttribute) Creates an instance bound to the given attribute. -
Method Summary
Modifier and TypeMethodDescriptionGets the attribute this instance moves data for.Class<?> 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 configuredCpoTransform.Class<?> 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 configuredCpoTransform.Invokes the bean's getter for the bound attribute.voidinvokeSetter(Object instanceObject) Invokes the bean's setter for the bound attribute.voidsetCpoAttribute(CpoAttribute cpoAttribute) 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).
-
Constructor Details
-
AbstractCpoData
Creates an instance bound to the given attribute.- Parameters:
cpoAttribute- the attribute this instance moves data for
-
-
Method Details
-
getCpoAttribute
Gets the attribute this instance moves data for.- Returns:
- the bound attribute
-
setCpoAttribute
Sets the attribute this instance moves data for.- Parameters:
cpoAttribute- the attribute to bind
-
transformIn
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:
transformInin interfaceCpoData- 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
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:
transformOutin interfaceCpoData- 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
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:
invokeGetterin interfaceCpoData- Returns:
- the value returned by the attribute's getter
- Throws:
UnsupportedOperationException- always, unless overridden by a subclassCpoException- if the getter cannot be invoked
-
invokeSetter
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:
invokeSetterin interfaceCpoData- Parameters:
instanceObject- the value to pass to the attribute's setter- Throws:
UnsupportedOperationException- always, unless overridden by a subclassCpoException- if the setter cannot be invoked
-
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 configuredCpoTransform.- Returns:
- the expected type of the raw datastore value
-
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 configuredCpoTransform.- Returns:
- the expected type of the value to bind to the datastore
-