Spring Data Core

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

Method Summary
<A extends Annotation>
A
findAnnotation(Class<A> annotationType)
          Looks up the annotation of the given type on the PersistentProperty.
<A extends Annotation>
A
findPropertyOrOwnerAnnotation(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.
 Class<?> getActualType()
          Returns the actual type of the property.
 Association<P> getAssociation()
           
 Class<?> getComponentType()
          Returns the component type of the type if it is a Collection.
 Field getField()
           
 Method getGetter()
          Returns the getter method to access the property value if available.
 Class<?> getMapValueType()
          Returns the type of the values if the property is a Map.
 String getName()
          The name of the property
 PersistentEntity<?,P> getOwner()
          Returns the PersistentEntity owning the current PersistentProperty.
 Iterable<? extends TypeInformation<?>> getPersistentEntityType()
          Returns the TypeInformation if the property references a PersistentEntity.
 Class<?> getRawType()
          Returns the raw type as it's pulled from from the reflected property.
 Method getSetter()
          Returns the setter method to set a property value.
 String getSpelExpression()
           
 Class<?> getType()
          The type of the property
 TypeInformation<?> getTypeInformation()
          Returns the TypeInformation of the property.
 boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
          Returns whether the PersistentProperty has an annotation of the given type.
 boolean isArray()
          Returns whether the property is an array.
 boolean isAssociation()
          Returns whether the property is an Association.
 boolean isCollectionLike()
          Returns whether the property is a Collection, Iterable or an array.
 boolean isEntity()
          Returns whether the type of the PersistentProperty is actually to be regarded as PersistentEntity in turn.
 boolean isIdProperty()
          Returns whether the property is a potential identifier property of the owning PersistentEntity.
 boolean isMap()
          Returns whether the property is a Map.
 boolean isTransient()
          Returns whether the property is transient.
 boolean isVersionProperty()
          Returns whether the current property is a potential version property of the owning PersistentEntity.
 boolean shallBePersisted()
           
 boolean usePropertyAccess()
          Returns whether property access shall be used for reading the property value.
 

Method Detail

getOwner

PersistentEntity<?,P> getOwner()
Returns the PersistentEntity owning the current PersistentProperty.

Returns:

getName

String getName()
The name of the property

Returns:
The property name

getType

Class<?> getType()
The type of the property

Returns:
The property type

getTypeInformation

TypeInformation<?> getTypeInformation()
Returns the TypeInformation of the property.

Returns:

getPersistentEntityType

Iterable<? extends TypeInformation<?>> getPersistentEntityType()
Returns the TypeInformation if the property references a PersistentEntity. Will return null in case it refers to a simple type. Will return Collection's component type or the Map's value type transparently.

Returns:

getGetter

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.

getSetter

Method getSetter()
Returns the setter method to set a property value. Might return null in case there is no setter available.


getField

Field getField()

getSpelExpression

String getSpelExpression()

getAssociation

Association<P> getAssociation()

isEntity

boolean isEntity()
Returns whether the type of the PersistentProperty is actually to be regarded as PersistentEntity in turn.

Returns:

isIdProperty

boolean isIdProperty()
Returns whether the property is a potential identifier property of the owning PersistentEntity. This method is mainly used by PersistentEntity implementation to discover id property candidates on PersistentEntity creation you should rather call PersistentEntity.isIdProperty(PersistentProperty) to determine whether the current property is the id property of that PersistentEntity under consideration.

Returns:

isVersionProperty

boolean isVersionProperty()
Returns whether the current property is a potential version property of the owning PersistentEntity. This method is mainly used by PersistentEntity implementation to discover version property candidates on PersistentEntity creation you should rather call PersistentEntity.isVersionProperty(PersistentProperty) to determine whether the current property is the version property of that PersistentEntity under consideration.

Returns:

isCollectionLike

boolean isCollectionLike()
Returns whether the property is a Collection, Iterable or an array.

Returns:

isMap

boolean isMap()
Returns whether the property is a Map.

Returns:

isArray

boolean isArray()
Returns whether the property is an array.

Returns:

isTransient

boolean isTransient()
Returns whether the property is transient.

Returns:

shallBePersisted

boolean shallBePersisted()

isAssociation

boolean isAssociation()
Returns whether the property is an Association.

Returns:

getComponentType

Class<?> getComponentType()
Returns the component type of the type if it is a Collection. Will return the type of the key if the property is a Map.

Returns:
the component type, the map's key type or null if neither Collection nor Map.

getRawType

Class<?> getRawType()
Returns the raw type as it's pulled from from the reflected property.

Returns:
the raw type of the property.

getMapValueType

Class<?> getMapValueType()
Returns the type of the values if the property is a Map.

Returns:
the map's value type or null if no Map

getActualType

Class<?> 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:

findAnnotation

<A extends Annotation> A findAnnotation(Class<A> annotationType)
Looks up the annotation of the given type on the PersistentProperty. 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 if present or null otherwise.
See Also:
AnnotationUtils.findAnnotation(Method, Class)

findPropertyOrOwnerAnnotation

<A extends Annotation> A findPropertyOrOwnerAnnotation(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. Usefull to lookup annotations that can be configured on the type but overridden on an individual property.

Parameters:
annotationType - must not be null.
Returns:

isAnnotationPresent

boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
Returns whether the PersistentProperty has an annotation of the given type.

Parameters:
annotationType - the annotation to lookup, must not be null.
Returns:
whether the PersistentProperty has an annotation of the given type.

usePropertyAccess

boolean 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:

Spring Data Core

Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.