Package org.apache.cayenne.reflect

# Interface ClassDescriptor

All Known Implementing Classes:
  `LazyClassDescriptorDecorator`, `PersistentDescriptor`

public interface ClassDescriptor
A runtime descriptor of an persistent class.

Since:
  1.2

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `createObject()`
  Creates a new instance of a class described by this object.
  `Map<String,DbEntity>`
  `getAdditionalDbEntities()`
  Returns information about additional db entities that is used for this ObjEntity (i.e.
  `PropertyDescriptor`
  `getDeclaredProperty(String propertyName)`
  Returns a Java Bean property descriptor matching property name or null if no such property is found.
  `Collection<ObjAttribute>`
  `getDiscriminatorColumns()`
  Returns a collection of ObjAttribute for the described class, its superclasses and subclasses, that participate in inheritance qualifier.
  `ObjEntity`
  `getEntity()`
  Returns an ObjEntity associated with this descriptor.
  `EntityInheritanceTree`
  `getEntityInheritanceTree()`
  `Expression`
  `getEntityQualifier()`
  Returns entity qualifier as a Cayenne expression that includes qualifiers for this entity and all subentities.
  `Collection<AttributeProperty>`
  `getIdProperties()`
  Returns a collection of the properties mapped to id columns.
  `Collection<ArcProperty>`
  `getMapArcProperties()`
  Returns a collection over the arc properties whose reverse arcs are to-many maps.
  `Class<?>`
  `getObjectClass()`
  Returns a class mapped by this descriptor.
  `PropertyDescriptor`
  `getProperty(String propertyName)`
  Returns a property descriptor matching property name, or null if no such property is found.
  `Collection<DbEntity>`
  `getRootDbEntities()`
  Returns a collection of DbEntities that are the root tables for this descriptor's ObjEntity.
  `ClassDescriptor`
  `getSubclassDescriptor(Class<?> objectClass)`
  Returns the most "specialized" descriptor for a given class.
  `ClassDescriptor`
  `getSuperclassDescriptor()`
  Returns a descriptor of the mapped superclass or null if the descriptor's entity sits at the top of inheritance hierarchy or no inheritance is mapped.
  `boolean`
  `hasSubclasses()`
  Returns whether this class has persistent subclasses.
  `void`
  `injectValueHolders(Object object)`
  Prepares object properties for access.
  `boolean`
  `isFault(Object object)`
  Returns true if an object is not fully resolved.
  `void`
  `shallowMerge(Object from, Object to)`
  Merges object properties from one object to another, avoiding traversal of the ArcProperties.
  `boolean`
  `visitAllProperties(PropertyVisitor visitor)`
  Passes the visitor to the properties "visit" method for a combination of all properties, including properties declared in this descriptor, its super descriptors, and all subdescriptors.
  `boolean`
  `visitDeclaredProperties(PropertyVisitor visitor)`
  Passes the visitor to the properties "visit" method for all properties declared in this descriptor.
  `boolean`
  `visitProperties(PropertyVisitor visitor)`
  Passes the visitor to the properties "visit" method for all properties declared in this descriptor and all its super-decsriptors.

- ## Method Details

  - ### getEntity

    ObjEntity getEntity()
    Returns an ObjEntity associated with this descriptor.
    Since:
      3.0

  - ### getRootDbEntities

    Collection<DbEntity> getRootDbEntities()
    Returns a collection of DbEntities that are the root tables for this descriptor's ObjEntity. Usually such collection would contain only one entity, however in cases involving subclass horizontal inheritance, it will be more than one, and in cases of abstract entities with no subclasses, the collection will be empty.
    Since:
      3.0

  - ### getAdditionalDbEntities

    Map<String,DbEntity> getAdditionalDbEntities()
    Returns information about additional db entities that is used for this ObjEntity (i.e. for flattened attributes).

    Keys are full paths for corresponding flattened attributes.

    Returns:
      information about additional db entities
    Since:
      4.1

  - ### getEntityInheritanceTree

    EntityInheritanceTree getEntityInheritanceTree()
    Since:
      3.0

  - ### hasSubclasses

    boolean hasSubclasses()
    Returns whether this class has persistent subclasses.
    Since:
      3.1

  - ### getObjectClass

    Class<?> getObjectClass()
    Returns a class mapped by this descriptor.

  - ### getSuperclassDescriptor

    ClassDescriptor getSuperclassDescriptor()
    Returns a descriptor of the mapped superclass or null if the descriptor's entity sits at the top of inheritance hierarchy or no inheritance is mapped.

  - ### getSubclassDescriptor

    ClassDescriptor getSubclassDescriptor(Class<?> objectClass)
    Returns the most "specialized" descriptor for a given class. This method assumes that the following is true:

         this.getObjectClass().isAssignableFrom(objectClass)

  - ### createObject

    Object createObject()
    Creates a new instance of a class described by this object.

  - ### injectValueHolders

    void injectValueHolders(Object object) throws PropertyException
    Prepares object properties for access. This may include injection of value holders into the object and such.
    Throws:
      `PropertyException`

  - ### shallowMerge

    void shallowMerge(Object from, Object to) throws PropertyException
    Merges object properties from one object to another, avoiding traversal of the ArcProperties.
    Throws:
      `PropertyException`

  - ### getProperty

    PropertyDescriptor getProperty(String propertyName)
    Returns a property descriptor matching property name, or null if no such property is found. Lookup includes properties from this descriptor and all its superclass descriptors. Returned property can be any one of `AttributeProperty`, `ToManyProperty`, `ToOneProperty`.

  - ### getDeclaredProperty

    PropertyDescriptor getDeclaredProperty(String propertyName)
    Returns a Java Bean property descriptor matching property name or null if no such property is found. Lookup DOES NOT including properties from the superclass descriptors. Returned property can be any one of `AttributeProperty`, `ToManyProperty`, `ToOneProperty`.

  - ### getIdProperties

    Collection<AttributeProperty> getIdProperties()
    Returns a collection of the properties mapped to id columns.
    Since:
      3.1

  - ### getDiscriminatorColumns

    Collection<ObjAttribute> getDiscriminatorColumns()
    Returns a collection of ObjAttribute for the described class, its superclasses and subclasses, that participate in inheritance qualifier. If a discriminator expression specifies a DbAttribute instead of an ObjAttribute, a synthetic ObjAttribute is created and returned.
    Since:
      3.1

  - ### getEntityQualifier

    Expression getEntityQualifier()
    Returns entity qualifier as a Cayenne expression that includes qualifiers for this entity and all subentities.
    Since:
      3.0

  - ### getMapArcProperties

    Collection<ArcProperty> getMapArcProperties()
    Returns a collection over the arc properties whose reverse arcs are to-many maps. I.e. for each ArcProperty in returned collection, the following is true:

         arc.getComplimentaryReverseArc() instanceof ToManyMapProperty

    Since:
      3.1

  - ### visitProperties

    boolean visitProperties(PropertyVisitor visitor)
    Passes the visitor to the properties "visit" method for all properties declared in this descriptor and all its super-decsriptors. Properties that are overridden in subdescriptors will include overridden information. Walkthrough is terminated in case one of the properties returns false. Returns true if all visited properties returned true, false - if one property returned false.

  - ### visitDeclaredProperties

    boolean visitDeclaredProperties(PropertyVisitor visitor)
    Passes the visitor to the properties "visit" method for all properties declared in this descriptor. This property set excludes inherited properties, even those that got overridden in this subclass. Walkthrough is terminated in case one of the properties returns false. Returns true if all visited properties returned true, false - if one property returned false.
    Since:
      3.0

  - ### visitAllProperties

    boolean visitAllProperties(PropertyVisitor visitor)
    Passes the visitor to the properties "visit" method for a combination of all properties, including properties declared in this descriptor, its super descriptors, and all subdescriptors. Walkthrough is terminated in case one of the properties returns false. Returns true if all visited properties returned true, false - if one property returned false.
    Since:
      3.0

  - ### isFault

    boolean isFault(Object object)
    Returns true if an object is not fully resolved.