Class CpoAttribute
java.lang.Object
org.synchronoss.cpo.core.meta.bean.CpoAttributeBean
org.synchronoss.cpo.core.meta.domain.CpoAttribute
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CassandraCpoAttribute,JdbcCpoAttribute
Runtime metadata for a single JavaBean-to-datastore attribute binding: extends
CpoAttributeBean's plain configuration data with the reflectively-resolved getter/setter Methods and, if configured, the CpoTransform instance and its transform methods. loadRunTimeInfo(CpoMetaDescriptor, Class) performs that resolution against a concrete bean
class and must be called before the getter/setter/transform accessors are used.- Author:
- dberry
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<D,J> CpoTransform <D, J> Gets the transform instance configured for this attribute, if any.intGets the integer identifier of this attribute's native data type.Class<?> Gets the return type of the bean's getter method.Class<?> Gets the parameter type expected by the bean's setter method.Gets the resolvedtransformInmethod of the configured transform.Class<?> Gets the parameter type of the configured transform'stransformInmethod.Gets the resolvedtransformOutmethod of the configured transform.invokeGetter(Object obj) Invokes the bean's getter method to read this attribute's value.voidinvokeSetter(Object instanceObject, CpoData cpoData) Invokes the bean's setter method, passing the value read fromcpoData.static booleanisPrimitiveAssignableFrom(Class<?> clazz, Class<?> paramClass) Gets whether one ofclazz/paramClassis a primitive type and the other is its corresponding wrapper class (e.g.voidloadRunTimeInfo(CpoMetaDescriptor metaDescriptor, Class<?> metaClass) Resolves this attribute's reflective getter/setter methods againstmetaClass, and instantiates and resolves its configured transform (if any) viametaDescriptor.voidsetDataTypeInt(int dataTypeInt) Sets the integer identifier of this attribute's native data type.toString()Gets the full field-by-field string representation of this attribute, as produced byCpoAttributeBean.toString().Methods inherited from class org.synchronoss.cpo.core.meta.bean.CpoAttributeBean
equals, getDataName, getDataType, getDescription, getJavaName, getJavaType, getTransformClassName, hashCode, setDataName, setDataType, setDescription, setJavaName, setJavaType, setTransformClassName
-
Constructor Details
-
CpoAttribute
public CpoAttribute()Creates an empty instance. CallloadRunTimeInfo(org.synchronoss.cpo.core.meta.CpoMetaDescriptor, java.lang.Class<?>)before use.
-
-
Method Details
-
getCpoTransform
Gets the transform instance configured for this attribute, if any.- Type Parameters:
D- the transform's datastore-side typeJ- the transform's Java-side type- Returns:
- the configured transform, or
nullif none is configured
-
getTransformInMethod
Gets the resolvedtransformInmethod of the configured transform.- Returns:
- the
transformInmethod, ornullif no transform is configured
-
getTransformOutMethod
Gets the resolvedtransformOutmethod of the configured transform.- Returns:
- the
transformOutmethod, ornullif no transform is configured
-
getTransformInParamType
Gets the parameter type of the configured transform'stransformInmethod.- Returns:
- the
transformInparameter type, ornullif no transform is configured
-
getSetterParamType
Gets the parameter type expected by the bean's setter method.- Returns:
- the setter's parameter type
-
getGetterReturnType
Gets the return type of the bean's getter method.- Returns:
- the getter's return type
-
setDataTypeInt
public void setDataTypeInt(int dataTypeInt) Sets the integer identifier of this attribute's native data type.- Parameters:
dataTypeInt- the native data type identifier
-
getDataTypeInt
public int getDataTypeInt()Gets the integer identifier of this attribute's native data type.- Returns:
- the native data type identifier
-
invokeSetter
Invokes the bean's setter method, passing the value read fromcpoData.- Parameters:
instanceObject- the bean instance to set the value oncpoData- the source of the value, viaCpoData.invokeGetter()- Throws:
CpoException- if the setter cannot be invoked
-
invokeGetter
Invokes the bean's getter method to read this attribute's value.- Parameters:
obj- the bean instance to read the value from- Returns:
- the value returned by the bean's getter
- Throws:
CpoException- if the getter cannot be invoked
-
isPrimitiveAssignableFrom
Gets whether one ofclazz/paramClassis a primitive type and the other is its corresponding wrapper class (e.g.int/Integer), determined heuristically by name and by checking for a wrapper constructor that accepts the primitive.- Parameters:
clazz- one of the two classes being comparedparamClass- the other class being compared- Returns:
trueif exactly one of the two is primitive and it is assignable to/from the other via boxing,falseotherwise
-
loadRunTimeInfo
public void loadRunTimeInfo(CpoMetaDescriptor metaDescriptor, Class<?> metaClass) throws CpoException Resolves this attribute's reflective getter/setter methods againstmetaClass, and instantiates and resolves its configured transform (if any) viametaDescriptor. Must be called beforeinvokeGetter(Object),invokeSetter(Object, CpoData), or any of the getter/setter/transform accessor methods are used.- Parameters:
metaDescriptor- the owning descriptor, used to instantiate the transform classmetaClass- the concrete bean class to resolve the getter/setter against, ornullto skip getter/setter resolution- Throws:
CpoException- if the transform cannot be instantiated, or the getter/setter cannot be found
-
toString
- Overrides:
toStringin classCpoAttributeBean
-
toStringFull
Gets the full field-by-field string representation of this attribute, as produced byCpoAttributeBean.toString().- Returns:
- the full string representation
-