Package org.apache.cayenne.reflect
Class PersistentDescriptor
java.lang.Object
org.apache.cayenne.reflect.PersistentDescriptor
- All Implemented Interfaces:
ClassDescriptor
A default ClassDescriptor implementation for persistent objects.
- Since:
- 3.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected Collection
<ObjAttribute> protected Map
<String, PropertyDescriptor> protected ObjEntity
protected EntityInheritanceTree
protected Expression
protected Collection
<AttributeProperty> protected Collection
<ArcProperty> protected Class
<?> protected Accessor
protected Map
<String, PropertyDescriptor> protected Collection
<DbEntity> protected Map
<String, ClassDescriptor> protected ClassDescriptor
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDeclaredProperty
(PropertyDescriptor property) Registers a property.void
addRootDbEntity
(DbEntity dbEntity) Adds a root DbEntity to the list of roots, filtering duplicates.void
addSubclassDescriptor
(String className, ClassDescriptor subclassDescriptor) Adds a subclass descriptor that maps to a given class name.void
addSuperProperty
(PropertyDescriptor property) Registers a superclass property.Creates a new instance of a class described by this object.Returns information about additional db entities that is used for this ObjEntity (i.e.getDeclaredProperty
(String propertyName) Returns a Java Bean property descriptor matching property name or null if no such property is found.Returns a collection of ObjAttribute for the described class, its superclasses and subclasses, that participate in inheritance qualifier.Returns an ObjEntity associated with this descriptor.Returns entity qualifier as a Cayenne expression that includes qualifiers for this entity and all subentities.Returns a collection of the properties mapped to id columns.Returns a collection over the arc properties whose reverse arcs are to-many maps.Class
<?> Returns a class mapped by this descriptor.getProperty
(String propertyName) Recursively looks up property descriptor in this class descriptor and all superclass descriptors.Returns a collection of DbEntities that are the root tables for this descriptor's ObjEntity.getSubclassDescriptor
(Class<?> objectClass) Returns the most "specialized" descriptor for a given class.Returns a descriptor of the mapped superclass or null if the descriptor's entity sits at the top of inheritance hierarchy.boolean
Returns whether this class has persistent subclasses.void
injectValueHolders
(Object object) Invokes 'prepareForAccess' of a super descriptor and then invokes 'prepareForAccess' of each declared property.boolean
Returns true if an object is not fully resolved.void
removeDeclaredProperty
(String propertyName) Removes declared property.void
setDiscriminatorColumns
(Collection<ObjAttribute> columns) void
void
setEntityInheritanceTree
(EntityInheritanceTree entityInheritanceTree) void
setEntityQualifier
(Expression entityQualifier) void
setPersistenceStateAccessor
(Accessor persistenceStateAccessor) void
setSuperclassDescriptor
(ClassDescriptor superclassDescriptor) void
shallowMerge
(Object from, Object to) Copies object properties from one object to another.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.
-
Field Details
-
superclassDescriptor
-
objectClass
-
declaredProperties
-
properties
-
subclassDescriptors
-
persistenceStateAccessor
-
entity
-
rootDbEntities
-
additionalDbEntities
-
entityInheritanceTree
-
idProperties
-
mapArcProperties
-
allDiscriminatorColumns
-
entityQualifier
-
-
Constructor Details
-
PersistentDescriptor
public PersistentDescriptor()Creates a PersistentDescriptor.
-
-
Method Details
-
setDiscriminatorColumns
-
addSuperProperty
Registers a superclass property. -
addDeclaredProperty
Registers a property. This method is useful to customize default ClassDescriptor generated from ObjEntity by adding new properties or overriding the standard ones. -
addRootDbEntity
Adds a root DbEntity to the list of roots, filtering duplicates. -
removeDeclaredProperty
Removes declared property. This method can be used to customize default ClassDescriptor generated from ObjEntity. -
addSubclassDescriptor
Adds a subclass descriptor that maps to a given class name. -
getEntity
Description copied from interface:ClassDescriptor
Returns an ObjEntity associated with this descriptor.- Specified by:
getEntity
in interfaceClassDescriptor
-
getRootDbEntities
Description copied from interface:ClassDescriptor
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.- Specified by:
getRootDbEntities
in interfaceClassDescriptor
-
getAdditionalDbEntities
Description copied from interface:ClassDescriptor
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.
- Specified by:
getAdditionalDbEntities
in interfaceClassDescriptor
- Returns:
- information about additional db entities
-
isFault
Description copied from interface:ClassDescriptor
Returns true if an object is not fully resolved.- Specified by:
isFault
in interfaceClassDescriptor
-
getObjectClass
Description copied from interface:ClassDescriptor
Returns a class mapped by this descriptor.- Specified by:
getObjectClass
in interfaceClassDescriptor
-
getSubclassDescriptor
Description copied from interface:ClassDescriptor
Returns the most "specialized" descriptor for a given class. This method assumes that the following is true:this.getObjectClass().isAssignableFrom(objectClass)
- Specified by:
getSubclassDescriptor
in interfaceClassDescriptor
-
getDiscriminatorColumns
Description copied from interface:ClassDescriptor
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.- Specified by:
getDiscriminatorColumns
in interfaceClassDescriptor
-
getIdProperties
Description copied from interface:ClassDescriptor
Returns a collection of the properties mapped to id columns.- Specified by:
getIdProperties
in interfaceClassDescriptor
-
getMapArcProperties
Description copied from interface:ClassDescriptor
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
- Specified by:
getMapArcProperties
in interfaceClassDescriptor
-
getProperty
Recursively looks up property descriptor in this class descriptor and all superclass descriptors.- Specified by:
getProperty
in interfaceClassDescriptor
-
getDeclaredProperty
Description copied from interface:ClassDescriptor
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 ofAttributeProperty
,ToManyProperty
,ToOneProperty
.- Specified by:
getDeclaredProperty
in interfaceClassDescriptor
-
getSuperclassDescriptor
Returns a descriptor of the mapped superclass or null if the descriptor's entity sits at the top of inheritance hierarchy.- Specified by:
getSuperclassDescriptor
in interfaceClassDescriptor
-
createObject
Creates a new instance of a class described by this object.- Specified by:
createObject
in interfaceClassDescriptor
-
injectValueHolders
Invokes 'prepareForAccess' of a super descriptor and then invokes 'prepareForAccess' of each declared property.- Specified by:
injectValueHolders
in interfaceClassDescriptor
- Throws:
PropertyException
-
shallowMerge
Copies object properties from one object to another. Invokes 'shallowCopy' of a super descriptor and then invokes 'shallowCopy' of each declared property.- Specified by:
shallowMerge
in interfaceClassDescriptor
- Throws:
PropertyException
-
visitDeclaredProperties
Description copied from interface:ClassDescriptor
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.- Specified by:
visitDeclaredProperties
in interfaceClassDescriptor
- Since:
- 3.0
-
visitAllProperties
Description copied from interface:ClassDescriptor
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.- Specified by:
visitAllProperties
in interfaceClassDescriptor
- Since:
- 3.0
-
visitProperties
Description copied from interface:ClassDescriptor
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.- Specified by:
visitProperties
in interfaceClassDescriptor
-
setPersistenceStateAccessor
-
setEntity
-
setSuperclassDescriptor
-
getEntityQualifier
Description copied from interface:ClassDescriptor
Returns entity qualifier as a Cayenne expression that includes qualifiers for this entity and all subentities.- Specified by:
getEntityQualifier
in interfaceClassDescriptor
-
setEntityQualifier
-
getEntityInheritanceTree
- Specified by:
getEntityInheritanceTree
in interfaceClassDescriptor
-
setEntityInheritanceTree
-
hasSubclasses
public boolean hasSubclasses()Description copied from interface:ClassDescriptor
Returns whether this class has persistent subclasses.- Specified by:
hasSubclasses
in interfaceClassDescriptor
-