Class AnnotationBasedPersistentProperty<P extends PersistentProperty<P>>
java.lang.Object
org.springframework.data.mapping.model.AbstractPersistentProperty<P>
org.springframework.data.mapping.model.AnnotationBasedPersistentProperty<P>
- All Implemented Interfaces:
PersistentProperty<P>
public abstract class AnnotationBasedPersistentProperty<P extends PersistentProperty<P>>
extends AbstractPersistentProperty<P>
Special
PersistentProperty
that takes annotations at a property into account.- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch
-
Constructor Summary
ConstructorDescriptionAnnotationBasedPersistentProperty
(Property property, PersistentEntity<?, P> owner, SimpleTypeHolder simpleTypeHolder) Creates a newAnnotationBasedPersistentProperty
. -
Method Summary
Modifier and TypeMethodDescription<A extends Annotation>
AfindAnnotation
(Class<A> annotationType) Returns the annotation found for the currentAnnotationBasedPersistentProperty
.<A extends Annotation>
AfindPropertyOrOwnerAnnotation
(Class<A> annotationType) Looks up the annotation of the given type on the property and the owning type if no annotation can be found on it.Return the type the property refers to in case it's an association, i.e.Inspects a potentially availableValue
annotation at the property and returns theString
value of it.boolean
isAnnotationPresent
(Class<? extends Annotation> annotationType) Returns whether the property carries the an annotation of the given type.boolean
Considers the property anAssociation
if it is annotated withReference
.boolean
Returns whether the property is a potential identifier property of the owningPersistentEntity
.boolean
boolean
Returns whether the current property is a potential version property of the owningPersistentEntity
.boolean
Returns whether the current property is writable, i.e. if the value held for it shall be written to the data store.toString()
boolean
Returns whether property access shall be used for reading the property value.Methods inherited from class org.springframework.data.mapping.model.AbstractPersistentProperty
createAssociation, equals, getActualType, getActualTypeInformation, getAssociation, getAssociationTargetType, getComponentType, getField, getGetter, getMapValueType, getName, getOwner, getPersistentEntityTypeInformation, getProperty, getRawType, getSetter, getType, getTypeInformation, getWither, hashCode, isArray, isCollectionLike, isEntity, isImmutable, isMap
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.data.mapping.PersistentProperty
getAccessorForOwner, getRequiredAnnotation, getRequiredAssociation, getRequiredField, getRequiredGetter, getRequiredSetter, getRequiredWither, hasActualTypeAnnotation
-
Constructor Details
-
AnnotationBasedPersistentProperty
public AnnotationBasedPersistentProperty(Property property, PersistentEntity<?, P> owner, SimpleTypeHolder simpleTypeHolder) Creates a newAnnotationBasedPersistentProperty
.- Parameters:
property
- must not be null.owner
- must not be null.
-
-
Method Details
-
getSpelExpression
Inspects a potentially availableValue
annotation at the property and returns theString
value of it.- Specified by:
getSpelExpression
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Overrides:
getSpelExpression
in classAbstractPersistentProperty<P extends PersistentProperty<P>>
- Returns:
- null if no expression defined.
- See Also:
-
isTransient
public boolean isTransient()- Specified by:
isTransient
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Overrides:
isTransient
in classAbstractPersistentProperty<P extends PersistentProperty<P>>
- Returns:
- See Also:
-
isIdProperty
public boolean isIdProperty()Description copied from interface:PersistentProperty
Returns whether the property is a potential identifier property of the owningPersistentEntity
. This method is mainly used byPersistentEntity
implementation to discover id property candidates onPersistentEntity
creation you should rather callPersistentEntity.isIdProperty(PersistentProperty)
to determine whether the current property is the id property of thatPersistentEntity
under consideration.- Returns:
- true if the id property.
-
isVersionProperty
public boolean isVersionProperty()Description copied from interface:PersistentProperty
Returns whether the current property is a potential version property of the owningPersistentEntity
. This method is mainly used byPersistentEntity
implementation to discover version property candidates onPersistentEntity
creation you should rather callPersistentEntity.isVersionProperty(PersistentProperty)
to determine whether the current property is the version property of thatPersistentEntity
under consideration.- Returns:
-
isAssociation
public boolean isAssociation()Considers the property anAssociation
if it is annotated withReference
.- Specified by:
isAssociation
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Overrides:
isAssociation
in classAbstractPersistentProperty<P extends PersistentProperty<P>>
- Returns:
-
isWritable
public boolean isWritable()Description copied from interface:PersistentProperty
Returns whether the current property is writable, i.e. if the value held for it shall be written to the data store.- Specified by:
isWritable
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Overrides:
isWritable
in classAbstractPersistentProperty<P extends PersistentProperty<P>>
- Returns:
-
findAnnotation
Returns the annotation found for the currentAnnotationBasedPersistentProperty
. Will prefer getters or setters annotations over ones found at the backing field as the former can be used to reconfigure the metadata in subclasses.- Parameters:
annotationType
- must not be null.- Returns:
- null if annotation type not found on property.
- See Also:
-
AnnotationUtils.findAnnotation(Method, Class)
-
findPropertyOrOwnerAnnotation
Description copied from interface:PersistentProperty
Looks up the annotation of the given type on the property and the owning type if no annotation can be found on it. Useful to lookup annotations that can be configured on the type but overridden on an individual property.- Parameters:
annotationType
- must not be null.- Returns:
- the annotation of the given type. Can be null.
-
isAnnotationPresent
Returns whether the property carries the an annotation of the given type.- Parameters:
annotationType
- the annotation type to look up.- Returns:
-
usePropertyAccess
public boolean usePropertyAccess()Description copied from interface:PersistentProperty
Returns whether property access shall be used for reading the property value. This means it will use the getter instead of field access.- Specified by:
usePropertyAccess
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Overrides:
usePropertyAccess
in classAbstractPersistentProperty<P extends PersistentProperty<P>>
- Returns:
-
getAssociationTargetTypeInformation
Description copied from interface:PersistentProperty
Return the type the property refers to in case it's an association, i.e.PersistentProperty.isAssociation()
returns true. That means, that implementations must return a non-null value from this method in that case. We also recommend to return null for non-associations right away to establish symmetry between this method andPersistentProperty.isAssociation()
.- Specified by:
getAssociationTargetTypeInformation
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Overrides:
getAssociationTargetTypeInformation
in classAbstractPersistentProperty<P extends PersistentProperty<P>>
- Returns:
- the type the property refers to in case it's an association, i.e.
PersistentProperty.isAssociation()
returns true.
-
toString
- Overrides:
toString
in classAbstractPersistentProperty<P extends PersistentProperty<P>>
-