Spring Data Commons

org.springframework.data.mapping.model
Class AbstractPersistentProperty<P extends PersistentProperty<P>>

java.lang.Object
  extended by 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 java.lang.Object
implements PersistentProperty<P>

Simple impementation of PersistentProperty.

Author:
Jon Brisbin , Oliver Gierke

Field Summary
protected  Association<P> association
           
protected  java.lang.reflect.Field field
           
protected  TypeInformation<?> information
           
protected  java.lang.String name
           
protected  PersistentEntity<?,P> owner
           
protected  java.beans.PropertyDescriptor propertyDescriptor
           
protected  java.lang.Class<?> rawType
           
 
Constructor Summary
AbstractPersistentProperty(java.lang.reflect.Field field, java.beans.PropertyDescriptor propertyDescriptor, PersistentEntity<?,P> owner, SimpleTypeHolder simpleTypeHolder)
           
 
Method Summary
protected abstract  Association<P> createAssociation()
           
 Association<P> getAssociation()
           
 java.lang.Class<?> getComponentType()
          Returns the component type of the type if it is a Collection.
 java.lang.reflect.Field getField()
           
 java.lang.Class<?> getMapValueType()
          Returns the type of the values if the property is a Map.
 java.lang.String getName()
          The name of the property
 PersistentEntity<?,P> getOwner()
           
 java.lang.Iterable<? extends TypeInformation<?>> getPersistentEntityType()
          Returns the TypeInformation if the property references a PersistentEntity.
 java.beans.PropertyDescriptor getPropertyDescriptor()
          Returns the PropertyDescriptor backing the PersistentProperty.
 java.lang.Class<?> getRawType()
          Returns the raw type as it's pulled from from the reflected property.
 java.lang.String getSpelExpression()
           
 java.lang.Class<?> getType()
          The type of the property
 TypeInformation<?> getTypeInformation()
           
 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.
protected  boolean isEntity()
           
 boolean isMap()
          Returns whether the property is a Map.
 boolean isTransient()
          Returns whether the property is transient.
 boolean shallBePersisted()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.data.mapping.PersistentProperty
isIdProperty
 

Field Detail

name

protected final java.lang.String name

propertyDescriptor

protected final java.beans.PropertyDescriptor propertyDescriptor

information

protected final TypeInformation<?> information

rawType

protected final java.lang.Class<?> rawType

field

protected final java.lang.reflect.Field field

association

protected final Association<P extends PersistentProperty<P>> association

owner

protected final PersistentEntity<?,P extends PersistentProperty<P>> owner
Constructor Detail

AbstractPersistentProperty

public AbstractPersistentProperty(java.lang.reflect.Field field,
                                  java.beans.PropertyDescriptor propertyDescriptor,
                                  PersistentEntity<?,P> owner,
                                  SimpleTypeHolder simpleTypeHolder)
Method Detail

createAssociation

protected abstract Association<P> createAssociation()

getOwner

public PersistentEntity<?,P> getOwner()
Specified by:
getOwner in interface PersistentProperty<P extends PersistentProperty<P>>

getName

public java.lang.String getName()
Description copied from interface: PersistentProperty
The name of the property

Specified by:
getName in interface PersistentProperty<P extends PersistentProperty<P>>
Returns:
The property name

getType

public java.lang.Class<?> getType()
Description copied from interface: PersistentProperty
The type of the property

Specified by:
getType in interface PersistentProperty<P extends PersistentProperty<P>>
Returns:
The property type

getRawType

public java.lang.Class<?> getRawType()
Description copied from interface: PersistentProperty
Returns the raw type as it's pulled from from the reflected property.

Specified by:
getRawType in interface PersistentProperty<P extends PersistentProperty<P>>
Returns:
the raw type of the property.

getTypeInformation

public TypeInformation<?> getTypeInformation()
Specified by:
getTypeInformation in interface PersistentProperty<P extends PersistentProperty<P>>

getPersistentEntityType

public java.lang.Iterable<? extends TypeInformation<?>> getPersistentEntityType()
Description copied from interface: PersistentProperty
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.

Specified by:
getPersistentEntityType in interface PersistentProperty<P extends PersistentProperty<P>>
Returns:

getPropertyDescriptor

public java.beans.PropertyDescriptor getPropertyDescriptor()
Description copied from interface: PersistentProperty
Returns the PropertyDescriptor backing the PersistentProperty.

Specified by:
getPropertyDescriptor in interface PersistentProperty<P extends PersistentProperty<P>>
Returns:

getField

public java.lang.reflect.Field getField()
Specified by:
getField in interface PersistentProperty<P extends PersistentProperty<P>>

getSpelExpression

public java.lang.String getSpelExpression()
Specified by:
getSpelExpression in interface PersistentProperty<P extends PersistentProperty<P>>

isTransient

public boolean isTransient()
Description copied from interface: PersistentProperty
Returns whether the property is transient.

Specified by:
isTransient in interface PersistentProperty<P extends PersistentProperty<P>>
Returns:

shallBePersisted

public boolean shallBePersisted()
Specified by:
shallBePersisted in interface PersistentProperty<P extends PersistentProperty<P>>

isAssociation

public boolean isAssociation()
Description copied from interface: PersistentProperty
Returns whether the property is an Association.

Specified by:
isAssociation in interface PersistentProperty<P extends PersistentProperty<P>>
Returns:

getAssociation

public Association<P> getAssociation()
Specified by:
getAssociation in interface PersistentProperty<P extends PersistentProperty<P>>

isCollectionLike

public boolean isCollectionLike()
Description copied from interface: PersistentProperty
Returns whether the property is a Collection, Iterable or an array.

Specified by:
isCollectionLike in interface PersistentProperty<P extends PersistentProperty<P>>
Returns:

isMap

public boolean isMap()
Description copied from interface: PersistentProperty
Returns whether the property is a Map.

Specified by:
isMap in interface PersistentProperty<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 interface PersistentProperty<P extends PersistentProperty<P>>
Returns:

isEntity

protected boolean isEntity()

getComponentType

public java.lang.Class<?> getComponentType()
Description copied from interface: PersistentProperty
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.

Specified by:
getComponentType in interface PersistentProperty<P extends PersistentProperty<P>>
Returns:
the component type, the map's key type or null if neither Collection nor Map.

getMapValueType

public java.lang.Class<?> getMapValueType()
Description copied from interface: PersistentProperty
Returns the type of the values if the property is a Map.

Specified by:
getMapValueType in interface PersistentProperty<P extends PersistentProperty<P>>
Returns:
the map's value type or null if no Map

Spring Data Commons

Copyright © 2012. All Rights Reserved.