Class AbstractPersistentProperty<P extends PersistentProperty<P>>
java.lang.Object
org.springframework.data.mapping.model.AbstractPersistentProperty<P>
- All Implemented Interfaces:
PersistentProperty<P>
- Direct Known Subclasses:
AnnotationBasedPersistentProperty
public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>>
extends Object
implements PersistentProperty<P>
Simple implementation of
PersistentProperty.- Author:
- Jon Brisbin, Oliver Gierke, Christoph Strobl, Mark Paluch
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractPersistentProperty(Property property, PersistentEntity<?, P> owner, SimpleTypeHolder simpleTypeHolder) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Association<P>booleanClass<?>Returns the actual type of the property.protected TypeInformation<?>Class<?>Return the type the property refers to in case it's an association, i.e.Return the type the property refers to in case it's an association, i.e.Class<?>Returns the component type of the type if it is aCollection.getField()Returns the getter method to access the property value if available.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.protected PropertyClass<?>Returns the raw type as it's pulled from from the reflected property.Returns the setter method to set a property value.Class<?>getType()The type of the propertyReturns theTypeInformationof the property.Returns the withMethodto set a property value on a new object instance.inthashCode()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 current property is immutable, i.e. if there is no setter or the backingFieldisfinal.booleanisMap()Returns whether the property is aMap.booleanReturns whether the property is transient.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 java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.data.mapping.PersistentProperty
findAnnotation, findPropertyOrOwnerAnnotation, getAccessorForOwner, getRequiredAnnotation, getRequiredAssociation, getRequiredField, getRequiredGetter, getRequiredSetter, getRequiredWither, hasActualTypeAnnotation, isAnnotationPresent, isIdProperty, isVersionProperty
-
Constructor Details
-
AbstractPersistentProperty
public AbstractPersistentProperty(Property property, PersistentEntity<?, P> owner, SimpleTypeHolder simpleTypeHolder)
-
-
Method Details
-
createAssociation
-
getOwner
Description copied from interface:PersistentPropertyReturns thePersistentEntityowning the currentPersistentProperty.- Specified by:
getOwnerin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- never null.
-
getName
Description copied from interface:PersistentPropertyThe name of the property- Specified by:
getNamein interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- The property name
-
getType
Description copied from interface:PersistentPropertyThe type of the property- Specified by:
getTypein interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- The property type
-
getRawType
Description copied from interface:PersistentPropertyReturns the raw type as it's pulled from from the reflected property.- Specified by:
getRawTypein interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- the raw type of the property.
-
getTypeInformation
Description copied from interface:PersistentPropertyReturns theTypeInformationof the property.- Specified by:
getTypeInformationin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
-
getPersistentEntityTypeInformation
Description copied from interface:PersistentPropertyReturns 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.- Specified by:
getPersistentEntityTypeInformationin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- never null.
-
getGetter
Description copied from interface:PersistentPropertyReturns 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.- Specified by:
getGetterin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- the getter method to access the property value if available, otherwise null.
-
getSetter
Description copied from interface:PersistentPropertyReturns the setter method to set a property value. Might return null in case there is no setter available.- Specified by:
getSetterin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- the setter method to set a property value if available, otherwise null.
-
getWither
Description copied from interface:PersistentPropertyReturns 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); } }- Specified by:
getWitherin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- the with
Methodto set a property value on a new object instance if available, otherwise null.
-
getField
- Specified by:
getFieldin interfacePersistentProperty<P extends PersistentProperty<P>>
-
getSpelExpression
- Specified by:
getSpelExpressionin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- null if no expression defined.
-
isTransient
public boolean isTransient()Description copied from interface:PersistentPropertyReturns whether the property is transient.- Specified by:
isTransientin interfacePersistentProperty<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>>- Returns:
-
isImmutable
public boolean isImmutable()Description copied from interface:PersistentPropertyReturns whether the current property is immutable, i.e. if there is no setter or the backingFieldisfinal.- Specified by:
isImmutablein interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- See Also:
-
isAssociation
public boolean isAssociation()Description copied from interface:PersistentPropertyReturns whether the property is anAssociation.- Specified by:
isAssociationin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
-
getAssociation
- Specified by:
getAssociationin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- null if property is not part of an
Association.
-
getAssociationTargetType
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:
getAssociationTargetTypein interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- the type the property refers to in case it's an association, i.e.
PersistentProperty.isAssociation()returns true.
-
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>>- Returns:
- the type the property refers to in case it's an association, i.e.
PersistentProperty.isAssociation()returns true.
-
isCollectionLike
public boolean isCollectionLike()Description copied from interface:PersistentPropertyReturns whether the property is aCollection,Iterableor an array.- Specified by:
isCollectionLikein interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
-
isMap
public boolean isMap()Description copied from interface:PersistentPropertyReturns whether the property is aMap.- Specified by:
isMapin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
-
isArray
public boolean isArray()Description copied from interface:PersistentPropertyReturns whether the property is an array.- Specified by:
isArrayin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
-
isEntity
public boolean isEntity()Description copied from interface:PersistentPropertyReturns whether the type of thePersistentPropertyis actually to be regarded asPersistentEntityin turn.- Specified by:
isEntityin interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- true a
PersistentEntity.
-
getComponentType
Description copied from interface:PersistentPropertyReturns the component type of the type if it is aCollection. Will return the type of the key if the property is aMap.- Specified by:
getComponentTypein interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- the component type, the map's key type or null if neither
CollectionnorMap.
-
getMapValueType
Description copied from interface:PersistentPropertyReturns the type of the values if the property is aMap.- Specified by:
getMapValueTypein interfacePersistentProperty<P extends PersistentProperty<P>>- Returns:
- the map's value type or null if no
Map
-
getActualType
Description copied from interface:PersistentPropertyReturns 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.- Specified by:
getActualTypein interfacePersistentProperty<P extends PersistentProperty<P>>- 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>>- Returns:
-
getProperty
-
getActualTypeInformation
-
equals
-
hashCode
public int hashCode() -
toString
-