Class CpoClass

java.lang.Object
org.synchronoss.cpo.core.meta.bean.CpoClassBean
org.synchronoss.cpo.core.meta.domain.CpoClass
All Implemented Interfaces:
Serializable, Comparable<CpoClass>, MetaDFVisitable
Direct Known Subclasses:
CpoClassCaseInsensitive, CpoClassCaseSensitive

public abstract class CpoClass extends CpoClassBean implements Comparable<CpoClass>, MetaDFVisitable
Runtime metadata for a JavaBean class mapped by CPO: its CpoAttributes, keyed both by Java property name and by datastore column name, and its CpoFunctionGroups (one per named CRUD operation group). Subclasses (CpoClassCaseSensitive, CpoClassCaseInsensitive) determine how the datastore-name lookup treats case.
Author:
dberry
See Also:
  • Constructor Details

    • CpoClass

      public CpoClass()
      Creates an empty instance.
  • Method Details

    • getMetaClass

      public Class<?> getMetaClass()
      Gets the reflectively-resolved Java class this metadata describes, once loadRunTimeInfo(CpoMetaDescriptor) has been called.
      Returns:
      the resolved Java class, or null if runtime info has not been loaded
    • addDataNameToMap

      public abstract void addDataNameToMap(String dataName, CpoAttribute cpoAttribute)
      Adds an attribute to the datastore-name lookup map, using whatever case-sensitivity policy the concrete subclass implements.
      Parameters:
      dataName - the datastore-side name to key on
      cpoAttribute - the attribute to add
    • removeDataNameFromMap

      public abstract void removeDataNameFromMap(String dataName)
      Removes an attribute from the datastore-name lookup map.
      Parameters:
      dataName - the datastore-side name to remove
    • getAttributeData

      public abstract CpoAttribute getAttributeData(String dataName)
      Gets the attribute bound to the given datastore-side name.
      Parameters:
      dataName - the datastore-side name to look up
      Returns:
      the matching attribute, or null if none is bound to dataName
    • addAttribute

      public void addAttribute(CpoAttribute cpoAttribute)
      Adds an attribute to this class, indexing it by both its Java name and its datastore name. A no-op if cpoAttribute is null.
      Parameters:
      cpoAttribute - the attribute to add
    • removeAttribute

      public void removeAttribute(CpoAttribute cpoAttribute)
      Removes an attribute from this class's Java-name and datastore-name indexes. A no-op if cpoAttribute is null.
      Parameters:
      cpoAttribute - the attribute to remove
    • getFunctionGroups

      public Map<String,CpoFunctionGroup> getFunctionGroups()
      Gets all function groups defined on this class, keyed internally by CRUD type and group name.
      Returns:
      the function groups map
    • getFunctionGroup

      public CpoFunctionGroup getFunctionGroup(Crud crud, String groupName) throws CpoException
      Gets the function group for the given CRUD type and group name.
      Parameters:
      crud - the CRUD operation type
      groupName - the function group name
      Returns:
      the matching function group
      Throws:
      CpoException - if no function group matches crud and groupName
    • existsFunctionGroup

      public boolean existsFunctionGroup(Crud crud, String groupName) throws CpoException
      Gets whether a function group exists for the given CRUD type and group name.
      Parameters:
      crud - the CRUD operation type
      groupName - the function group name
      Returns:
      true if a matching function group exists, false otherwise
      Throws:
      CpoException - if the lookup fails
    • addFunctionGroup

      public CpoFunctionGroup addFunctionGroup(CpoFunctionGroup group)
      Adds a function group to this class, keyed by its CRUD type and name. A no-op (returning null) if group is null.
      Parameters:
      group - the function group to add
      Returns:
      the function group previously registered under the same key, or null if none
    • removeFunctionGroup

      public void removeFunctionGroup(CpoFunctionGroup group)
      Removes a function group from this class. A no-op if group is null.
      Parameters:
      group - the function group to remove
    • compareTo

      public int compareTo(CpoClass anotherCpoClass)

      Orders classes by CpoClassBean.getName().

      Specified by:
      compareTo in interface Comparable<CpoClass>
    • acceptMetaDFVisitor

      public void acceptMetaDFVisitor(MetaVisitor visitor)
      Accepts a visitor, depth-first: this node is visited, then each child accepts the visitor in turn.

      Visits this class, then its attributes (sorted by Java name), then each function group (sorted by name) together with its functions and each function's arguments, all in their natural/declared order.

      Specified by:
      acceptMetaDFVisitor in interface MetaDFVisitable
      Parameters:
      visitor - the visitor to accept
    • loadRunTimeInfo

      public void loadRunTimeInfo(CpoMetaDescriptor metaDescriptor) throws CpoException
      Resolves this class's reflective metadata (the concrete Java class, and each attribute's getter/setter/transform) against the classpath, if not already resolved. Idempotent and thread-safe; subsequent calls after the first successful resolution are no-ops.
      Parameters:
      metaDescriptor - the owning descriptor, passed through to each attribute's resolution
      Throws:
      CpoException - if the class cannot be found, or an attribute cannot be resolved
    • getAttributeJava

      public CpoAttribute getAttributeJava(String javaName)
      Gets the attribute bound to the given JavaBean property name.
      Parameters:
      javaName - the JavaBean property name to look up
      Returns:
      the matching attribute, or null if javaName is null or no attribute is bound to it
    • toString

      public String toString()

      Returns this class's name.

      Overrides:
      toString in class CpoClassBean
    • toStringFull

      public String toStringFull()
      Gets the full field-by-field string representation of this class, as produced by CpoClassBean.toString().
      Returns:
      the full string representation
    • emptyMaps

      public void emptyMaps()
      Clears this class's attribute and function group maps, discarding all metadata.