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
ConstructorsConstructorDescriptionAnnotationBasedPersistentProperty(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.booleanisAnnotationPresent(Class<? extends Annotation> annotationType) Returns whether the property carries the an annotation of the given type.booleanConsiders the property anAssociationif it is annotated withReference.booleanReturns whether the property is a potential identifier property of the owningPersistentEntity.booleanbooleanReturns whether the current property is a potential version property of the owningPersistentEntity.booleanReturns whether the current property is writable, i.e. if the value held for it shall be written to the data store.toString()booleanReturns 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, isMapMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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 availableValueannotation at the property and returns theStringvalue of it.- Specified by:
getSpelExpressionin interfacePersistentProperty<P extends PersistentProperty<P>>- Overrides:
getSpelExpressionin classAbstractPersistentProperty<P extends PersistentProperty<P>>- Returns:
- null if no expression defined.
- See Also:
-
isTransient
public boolean isTransient()- Specified by:
isTransientin interfacePersistentProperty<P extends PersistentProperty<P>>- Overrides:
isTransientin classAbstractPersistentProperty<P extends PersistentProperty<P>>- Returns:
- See Also:
-
isIdProperty
public boolean isIdProperty()Description copied from interface:PersistentPropertyReturns whether the property is a potential identifier property of the owningPersistentEntity. This method is mainly used byPersistentEntityimplementation to discover id property candidates onPersistentEntitycreation you should rather callPersistentEntity.isIdProperty(PersistentProperty)to determine whether the current property is the id property of thatPersistentEntityunder consideration.- Returns:
- true if the id property.
-
isVersionProperty
public boolean isVersionProperty()Description copied from interface:PersistentPropertyReturns whether the current property is a potential version property of the owningPersistentEntity. This method is mainly used byPersistentEntityimplementation to discover version property candidates onPersistentEntitycreation you should rather callPersistentEntity.isVersionProperty(PersistentProperty)to determine whether the current property is the version property of thatPersistentEntityunder consideration.- Returns:
-
isAssociation
public boolean isAssociation()Considers the property anAssociationif it is annotated withReference.- Specified by:
isAssociationin interfacePersistentProperty<P extends PersistentProperty<P>>- Overrides:
isAssociationin classAbstractPersistentProperty<P extends PersistentProperty<P>>- Returns:
-
isWritable
public boolean isWritable()Description copied from interface:PersistentPropertyReturns whether the current property is writable, i.e. if the value held for it shall be written to the data store.- Specified by:
isWritablein interfacePersistentProperty<P extends PersistentProperty<P>>- Overrides:
isWritablein 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:
-
findPropertyOrOwnerAnnotation
Description copied from interface:PersistentPropertyLooks 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:PersistentPropertyReturns whether property access shall be used for reading the property value. This means it will use the getter instead of field access.- Specified by:
usePropertyAccessin interfacePersistentProperty<P extends PersistentProperty<P>>- Overrides:
usePropertyAccessin classAbstractPersistentProperty<P extends PersistentProperty<P>>- Returns:
-
getAssociationTargetTypeInformation
Description copied from interface:PersistentPropertyReturn 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:
getAssociationTargetTypeInformationin interfacePersistentProperty<P extends PersistentProperty<P>>- Overrides:
getAssociationTargetTypeInformationin 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:
toStringin classAbstractPersistentProperty<P extends PersistentProperty<P>>
-