Package org.springframework.data.mapping
Interface PersistentProperty<P extends PersistentProperty<P>>
- All Known Implementing Classes:
- AbstractPersistentProperty,- AnnotationBasedPersistentProperty
public interface PersistentProperty<P extends PersistentProperty<P>>
- Author:
- Graeme Rocher, Jon Brisbin, Oliver Gierke, Mark Paluch, Jens Schauder, Christoph Strobl, Johannes Englmeier
- 
Method SummaryModifier and TypeMethodDescription<A extends Annotation>
 @Nullable AfindAnnotation(Class<A> annotationType) Looks up the annotation of the given type on thePersistentProperty.<A extends Annotation>
 @Nullable 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.default <T> PersistentPropertyAccessor<T>getAccessorForOwner(T owner) Returns aPersistentPropertyAccessorfor the current property's owning value.Class<?>Returns the actual type of the property.@Nullable Association<P>@Nullable Class<?>Return the type the property refers to in case it's an association, i.e.@Nullable TypeInformation<?>Return the type the property refers to in case it's an association, i.e.@Nullable Class<?>Returns the component type of the type if it is aCollection.@Nullable FieldgetField()@Nullable MethodReturns the getter method to access the property value if available.@Nullable Class<?>Returns the type of the values if the property is aMap.getName()The name of the propertygetOwner()Returns thePersistentEntityowning the currentPersistentProperty.Iterable<? extends TypeInformation<?>>Returns the detectedTypeInformationsif the property references aPersistentEntity.Class<?>Returns the raw type as it's pulled from from the reflected property.default <A extends Annotation>
 AgetRequiredAnnotation(Class<A> annotationType) Looks up the annotation of the given type on thePersistentProperty.default Association<P>Get theAssociationof this property.default Fielddefault Methoddefault Methoddefault Method@Nullable MethodReturns the setter method to set a property value.@Nullable StringClass<?>getType()The type of the propertyReturns theTypeInformationof the property.@Nullable MethodReturns the withMethodto set a property value on a new object instance.default booleanhasActualTypeAnnotation(Class<? extends Annotation> annotationType) Returns whether the actual type of the property carries the given annotation.booleanisAnnotationPresent(Class<? extends Annotation> annotationType) Returns whether thePersistentPropertyhas an annotation of the given type.booleanisArray()Returns whether the property is an array.booleanReturns whether the property is anAssociation.booleanReturns whether the property is aCollection,Iterableor an array.booleanisEntity()Returns whether the type of thePersistentPropertyis actually to be regarded asPersistentEntityin turn.booleanReturns whether the property is a potential identifier property of the owningPersistentEntity.booleanReturns whether the current property is immutable, i.e. if there is no setter or the backingFieldisfinal.booleanisMap()Returns whether the property is aMap.booleanReturns whether the current property is readable throughPersistentPropertyAccessor, i.e. if it is notisTransient(), if the value can be set on the current instance or read to create a new instance as pergetWither()or via Kotlin Copy methods.booleanReturns whether the property is transient.booleanReturns 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.booleanReturns whether property access shall be used for reading the property value.
- 
Method Details- 
getOwnerPersistentEntity<?,P> getOwner()Returns thePersistentEntityowning the currentPersistentProperty.- Returns:
- never null.
 
- 
getNameString getName()The name of the property- Returns:
- The property name
 
- 
getTypeClass<?> getType()The type of the property- Returns:
- The property type
 
- 
getTypeInformationTypeInformation<?> getTypeInformation()Returns theTypeInformationof the property.- Returns:
 
- 
getPersistentEntityTypeInformationIterable<? extends TypeInformation<?>> getPersistentEntityTypeInformation()Returns the detectedTypeInformationsif the property references aPersistentEntity. Will return an emptyIterablein case it refers to a simple type. Will return theCollection's component types or theMap's value type transparently.- Returns:
- never null.
- Since:
- 2.6
 
- 
getGetter@Nullable Method getGetter()Returns the getter method to access the property value if available. Might return null in case there is no getter method with a return type assignable to the actual property's type.- Returns:
- the getter method to access the property value if available, otherwise null.
 
- 
getRequiredGetter
- 
getSetter@Nullable Method getSetter()Returns the setter method to set a property value. Might return null in case there is no setter available.- Returns:
- the setter method to set a property value if available, otherwise null.
 
- 
getRequiredSetter
- 
getWither@Nullable Method getWither()Returns the withMethodto set a property value on a new object instance. Might return null in case there is no with available.With methodsare property-bound instancemethodsthat accept a single argument of the property type creating a new object instance.class Person { final String id; final String name; // … Person withName(String name) { return new Person(this.id, name); } }- Returns:
- the with Methodto set a property value on a new object instance if available, otherwise null.
- Since:
- 2.1
 
- 
getRequiredWither
- 
getField@Nullable Field getField()
- 
getRequiredField
- 
getSpelExpression@Nullable String getSpelExpression()- Returns:
- null if no expression defined.
 
- 
getAssociation@Nullable Association<P> getAssociation()- Returns:
- null if property is not part of an Association.
 
- 
getRequiredAssociationGet theAssociationof this property.- Returns:
- never null.
- Throws:
- IllegalStateException- if not involved in an- Association.
 
- 
isEntityboolean isEntity()Returns whether the type of thePersistentPropertyis actually to be regarded asPersistentEntityin turn.- Returns:
- true a PersistentEntity.
 
- 
isIdPropertyboolean isIdProperty()Returns 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.
 
- 
isVersionPropertyboolean isVersionProperty()Returns 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:
 
- 
isCollectionLikeboolean isCollectionLike()Returns whether the property is aCollection,Iterableor an array.- Returns:
 
- 
isMapboolean isMap()Returns whether the property is aMap.- Returns:
 
- 
isArrayboolean isArray()Returns whether the property is an array.- Returns:
 
- 
isTransientboolean isTransient()Returns whether the property is transient.- Returns:
 
- 
isWritableboolean isWritable()Returns whether the current property is writable, i.e. if the value held for it shall be written to the data store.- Returns:
- Since:
- 1.9
 
- 
isReadableboolean isReadable()Returns whether the current property is readable throughPersistentPropertyAccessor, i.e. if it is notisTransient(), if the value can be set on the current instance or read to create a new instance as pergetWither()or via Kotlin Copy methods.- Returns:
- Since:
- 3.2
 
- 
isImmutableboolean isImmutable()Returns whether the current property is immutable, i.e. if there is no setter or the backingFieldisfinal.- Returns:
- Since:
- 2.1
- See Also:
 
- 
isAssociationboolean isAssociation()Returns whether the property is anAssociation.- Returns:
 
- 
getComponentType@Nullable Class<?> getComponentType()Returns the component type of the type if it is aCollection. Will return the type of the key if the property is aMap.- Returns:
- the component type, the map's key type or null if neither CollectionnorMap.
 
- 
getRawTypeClass<?> getRawType()Returns the raw type as it's pulled from from the reflected property.- Returns:
- the raw type of the property.
 
- 
getMapValueType@Nullable Class<?> getMapValueType()Returns the type of the values if the property is aMap.- Returns:
- the map's value type or null if no Map
 
- 
getActualTypeClass<?> getActualType()Returns the actual type of the property. This will be the original property type if no generics were used, the component type for collection-like types and arrays as well as the value type for map properties.- Returns:
 
- 
findAnnotationLooks up the annotation of the given type on thePersistentProperty. Will inspect accessors and the potentially backing field and traverse accessor methods to potentially available super types.- Parameters:
- annotationType- the annotation to look up, must not be null.
- Returns:
- the annotation of the given type. Can be null.
- See Also:
 
- 
getRequiredAnnotationdefault <A extends Annotation> A getRequiredAnnotation(Class<A> annotationType) throws IllegalStateException Looks up the annotation of the given type on thePersistentProperty. Will inspect accessors and the potentially backing field and traverse accessor methods to potentially available super types.- Parameters:
- annotationType- the annotation to look up, must not be null.
- Returns:
- the annotation of the given type.
- Throws:
- IllegalStateException- if the required- annotationTypeis not found.
- Since:
- 2.0
 
- 
findPropertyOrOwnerAnnotationLooks 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.
 
- 
isAnnotationPresentReturns whether thePersistentPropertyhas an annotation of the given type.- Parameters:
- annotationType- the annotation to lookup, must not be null.
- Returns:
- whether the PersistentPropertyhas an annotation of the given type.
 
- 
usePropertyAccessboolean usePropertyAccess()Returns whether property access shall be used for reading the property value. This means it will use the getter instead of field access.- Returns:
 
- 
hasActualTypeAnnotationReturns whether the actual type of the property carries the given annotation.- Parameters:
- annotationType- must not be null.
- Returns:
- Since:
- 2.1
- See Also:
 
- 
getAssociationTargetType@Nullable Class<?> getAssociationTargetType()Return the type the property refers to in case it's an association, i.e.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 andisAssociation().- Returns:
- the type the property refers to in case it's an association, i.e. isAssociation()returns true.
- Since:
- 2.1
 
- 
getAssociationTargetTypeInformation@Nullable TypeInformation<?> getAssociationTargetTypeInformation()Return the type the property refers to in case it's an association, i.e.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 andisAssociation().- Returns:
- the type the property refers to in case it's an association, i.e. isAssociation()returns true.
- Since:
- 2.6
 
- 
getAccessorForOwnerReturns aPersistentPropertyAccessorfor the current property's owning value.- Parameters:
- owner- must not be null.
- Returns:
- will never be null.
- Since:
- 2.3
 
 
-