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

public class CpoAttribute extends CpoAttributeBean
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 Details

  • Method Details

    • getCpoTransform

      public <D, J> CpoTransform<D,J> getCpoTransform()
      Gets the transform instance configured for this attribute, if any.
      Type Parameters:
      D - the transform's datastore-side type
      J - the transform's Java-side type
      Returns:
      the configured transform, or null if none is configured
    • getTransformInMethod

      public Method getTransformInMethod()
      Gets the resolved transformIn method of the configured transform.
      Returns:
      the transformIn method, or null if no transform is configured
    • getTransformOutMethod

      public Method getTransformOutMethod()
      Gets the resolved transformOut method of the configured transform.
      Returns:
      the transformOut method, or null if no transform is configured
    • getTransformInParamType

      public Class<?> getTransformInParamType()
      Gets the parameter type of the configured transform's transformIn method.
      Returns:
      the transformIn parameter type, or null if no transform is configured
    • getSetterParamType

      public Class<?> getSetterParamType()
      Gets the parameter type expected by the bean's setter method.
      Returns:
      the setter's parameter type
    • getGetterReturnType

      public Class<?> 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

      public void invokeSetter(Object instanceObject, CpoData cpoData) throws CpoException
      Invokes the bean's setter method, passing the value read from cpoData.
      Parameters:
      instanceObject - the bean instance to set the value on
      cpoData - the source of the value, via CpoData.invokeGetter()
      Throws:
      CpoException - if the setter cannot be invoked
    • invokeGetter

      public Object invokeGetter(Object obj) throws CpoException
      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

      public static boolean isPrimitiveAssignableFrom(Class<?> clazz, Class<?> paramClass)
      Gets whether one of clazz/paramClass is 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 compared
      paramClass - the other class being compared
      Returns:
      true if exactly one of the two is primitive and it is assignable to/from the other via boxing, false otherwise
    • loadRunTimeInfo

      public void loadRunTimeInfo(CpoMetaDescriptor metaDescriptor, Class<?> metaClass) throws CpoException
      Resolves this attribute's reflective getter/setter methods against metaClass, and instantiates and resolves its configured transform (if any) via metaDescriptor. Must be called before invokeGetter(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 class
      metaClass - the concrete bean class to resolve the getter/setter against, or null to skip getter/setter resolution
      Throws:
      CpoException - if the transform cannot be instantiated, or the getter/setter cannot be found
    • toString

      public String toString()
      Overrides:
      toString in class CpoAttributeBean
    • toStringFull

      public String toStringFull()
      Gets the full field-by-field string representation of this attribute, as produced by CpoAttributeBean.toString().
      Returns:
      the full string representation