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
ConstructorDescriptionAbstractPersistentProperty
(Property property, PersistentEntity<?, P> owner, SimpleTypeHolder simpleTypeHolder) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Association<P>
boolean
Class<?>
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 thePersistentEntity
owning the currentPersistentProperty
.Iterable<? extends TypeInformation<?>>
Returns the detectedTypeInformations
if the property references aPersistentEntity
.protected Property
Class<?>
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 theTypeInformation
of the property.Returns the withMethod
to set a property value on a new object instance.int
hashCode()
boolean
isArray()
Returns whether the property is an array.boolean
Returns whether the property is anAssociation
.boolean
Returns whether the property is aCollection
,Iterable
or an array.boolean
isEntity()
Returns whether the type of thePersistentProperty
is actually to be regarded asPersistentEntity
in turn.boolean
Returns whether the current property is immutable, i.e. if there is no setter or the backingField
isfinal
.boolean
isMap()
Returns whether the property is aMap
.boolean
Returns whether the property is transient.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 java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.data.mapping.PersistentProperty
findAnnotation, findPropertyOrOwnerAnnotation, getAccessorForOwner, getRequiredAnnotation, getRequiredAssociation, getRequiredField, getRequiredGetter, getRequiredSetter, getRequiredWither, getValueConverterType, hasActualTypeAnnotation, hasValueConverter, isAnnotationPresent, isIdProperty, isVersionProperty
-
Constructor Details
-
AbstractPersistentProperty
public AbstractPersistentProperty(Property property, PersistentEntity<?, P> owner, SimpleTypeHolder simpleTypeHolder)
-
-
Method Details
-
createAssociation
-
getOwner
Description copied from interface:PersistentProperty
Returns thePersistentEntity
owning the currentPersistentProperty
.- Specified by:
getOwner
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- never null.
-
getName
Description copied from interface:PersistentProperty
The name of the property- Specified by:
getName
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- The property name
-
getType
Description copied from interface:PersistentProperty
The type of the property- Specified by:
getType
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- The property type
-
getRawType
Description copied from interface:PersistentProperty
Returns the raw type as it's pulled from from the reflected property.- Specified by:
getRawType
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- the raw type of the property.
-
getTypeInformation
Description copied from interface:PersistentProperty
Returns theTypeInformation
of the property.- Specified by:
getTypeInformation
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
-
getPersistentEntityTypeInformation
Description copied from interface:PersistentProperty
Returns the detectedTypeInformations
if the property references aPersistentEntity
. Will return an emptyIterable
in case it refers to a simple type. Will return theCollection
's component types or theMap
's value type transparently.- Specified by:
getPersistentEntityTypeInformation
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- never null.
-
getGetter
Description copied from interface:PersistentProperty
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.- Specified by:
getGetter
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- the getter method to access the property value if available, otherwise null.
-
getSetter
Description copied from interface:PersistentProperty
Returns the setter method to set a property value. Might return null in case there is no setter available.- Specified by:
getSetter
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- the setter method to set a property value if available, otherwise null.
-
getWither
Description copied from interface:PersistentProperty
Returns the withMethod
to set a property value on a new object instance. Might return null in case there is no with available.With
methods
are property-bound instancemethods
that 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:
getWither
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- the with
Method
to set a property value on a new object instance if available, otherwise null.
-
getField
- Specified by:
getField
in interfacePersistentProperty<P extends PersistentProperty<P>>
-
getSpelExpression
- Specified by:
getSpelExpression
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- null if no expression defined.
-
isTransient
public boolean isTransient()Description copied from interface:PersistentProperty
Returns whether the property is transient.- Specified by:
isTransient
in interfacePersistentProperty<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>>
- Returns:
-
isImmutable
public boolean isImmutable()Description copied from interface:PersistentProperty
Returns whether the current property is immutable, i.e. if there is no setter or the backingField
isfinal
.- Specified by:
isImmutable
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- See Also:
-
isAssociation
public boolean isAssociation()Description copied from interface:PersistentProperty
Returns whether the property is anAssociation
.- Specified by:
isAssociation
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
-
getAssociation
- Specified by:
getAssociation
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- null if property is not part of an
Association
.
-
getAssociationTargetType
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:
getAssociationTargetType
in 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: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>>
- 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:PersistentProperty
Returns whether the property is aCollection
,Iterable
or an array.- Specified by:
isCollectionLike
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
-
isMap
public boolean isMap()Description copied from interface:PersistentProperty
Returns whether the property is aMap
.- Specified by:
isMap
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
-
isArray
public boolean isArray()Description copied from interface:PersistentProperty
Returns whether the property is an array.- Specified by:
isArray
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
-
isEntity
public boolean isEntity()Description copied from interface:PersistentProperty
Returns whether the type of thePersistentProperty
is actually to be regarded asPersistentEntity
in turn.- Specified by:
isEntity
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- true a
PersistentEntity
.
-
getComponentType
Description copied from interface:PersistentProperty
Returns the component type of the type if it is aCollection
. Will return the type of the key if the property is aMap
.- Specified by:
getComponentType
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- the component type, the map's key type or null if neither
Collection
norMap
.
-
getMapValueType
Description copied from interface:PersistentProperty
Returns the type of the values if the property is aMap
.- Specified by:
getMapValueType
in interfacePersistentProperty<P extends PersistentProperty<P>>
- Returns:
- the map's value type or null if no
Map
-
getActualType
Description copied from interface:PersistentProperty
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.- Specified by:
getActualType
in interfacePersistentProperty<P extends PersistentProperty<P>>
- 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>>
- Returns:
-
getProperty
-
getActualTypeInformation
-
equals
-
hashCode
public int hashCode() -
toString
-