Spring Data Commons

org.springframework.data.mapping
Class BasicPersistentEntity<T,P extends PersistentProperty<P>>

java.lang.Object
  extended by org.springframework.data.mapping.BasicPersistentEntity<T,P>
All Implemented Interfaces:
PersistentEntity<T,P>, MutablePersistentEntity<T,P>

public class BasicPersistentEntity<T,P extends PersistentProperty<P>>
extends Object
implements MutablePersistentEntity<T,P>

Simple value object to capture information of PersistentEntitys.

Author:
Jon Brisbin

Field Summary
protected  Map<String,Association<P>> associations
           
protected  P idProperty
           
protected  TypeInformation<T> information
           
protected  Map<String,P> persistentProperties
           
protected  PreferredConstructor<T> preferredConstructor
           
 
Constructor Summary
BasicPersistentEntity(TypeInformation<T> information)
          Creates a new BasicPersistentEntity from the given TypeInformation.
 
Method Summary
 void addAssociation(Association<P> association)
          Adds an Association to the entity.
 void addPersistentProperty(P property)
          Adds a PersistentProperty to the entity.
 void doWithAssociations(AssociationHandler<P> handler)
           
 void doWithProperties(PropertyHandler<P> handler)
           
 Collection<Association<P>> getAssociations()
          A list of the associations for this entity.
 P getIdProperty()
          Returns the id property of the PersistentEntity.
 String getName()
          The entity name including any package prefix
 Collection<P> getPersistentProperties()
          A list of properties to be persisted
 P getPersistentProperty(String name)
          Obtains a PersistentProperty instance by name
 Collection<String> getPersistentPropertyNames()
          A list of property names
 PreferredConstructor<T> getPreferredConstructor()
           
 Class<T> getType()
           
 TypeInformation<T> getTypeInformation()
           
 void setIdProperty(P property)
          Sets the id property for the entity.
 void verify()
          Callback method to trigger validation of the PersistentEntity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

preferredConstructor

protected final PreferredConstructor<T> preferredConstructor

information

protected final TypeInformation<T> information

persistentProperties

protected final Map<String,P extends PersistentProperty<P>> persistentProperties

associations

protected final Map<String,Association<P extends PersistentProperty<P>>> associations

idProperty

protected P extends PersistentProperty<P> idProperty
Constructor Detail

BasicPersistentEntity

public BasicPersistentEntity(TypeInformation<T> information)
Creates a new BasicPersistentEntity from the given TypeInformation.

Parameters:
information -
Method Detail

getPreferredConstructor

public PreferredConstructor<T> getPreferredConstructor()
Specified by:
getPreferredConstructor in interface PersistentEntity<T,P extends PersistentProperty<P>>

getName

public String getName()
Description copied from interface: PersistentEntity
The entity name including any package prefix

Specified by:
getName in interface PersistentEntity<T,P extends PersistentProperty<P>>
Returns:
The entity name

getIdProperty

public P getIdProperty()
Description copied from interface: PersistentEntity
Returns the id property of the PersistentEntity. Must never return null as a PersistentEntity instance must not be created if there is no id property.

Specified by:
getIdProperty in interface PersistentEntity<T,P extends PersistentProperty<P>>
Returns:
the id property of the PersistentEntity.

setIdProperty

public void setIdProperty(P property)
Description copied from interface: MutablePersistentEntity
Sets the id property for the entity.

Specified by:
setIdProperty in interface MutablePersistentEntity<T,P extends PersistentProperty<P>>

getPersistentProperties

public Collection<P> getPersistentProperties()
Description copied from interface: PersistentEntity
A list of properties to be persisted

Specified by:
getPersistentProperties in interface PersistentEntity<T,P extends PersistentProperty<P>>
Returns:
A list of PersistentProperty instances

addPersistentProperty

public void addPersistentProperty(P property)
Description copied from interface: MutablePersistentEntity
Adds a PersistentProperty to the entity.

Specified by:
addPersistentProperty in interface MutablePersistentEntity<T,P extends PersistentProperty<P>>

getAssociations

public Collection<Association<P>> getAssociations()
Description copied from interface: PersistentEntity
A list of the associations for this entity. This is typically a subset of the list returned by PersistentEntity.getPersistentProperties()

Specified by:
getAssociations in interface PersistentEntity<T,P extends PersistentProperty<P>>
Returns:
A list of associations

addAssociation

public void addAssociation(Association<P> association)
Description copied from interface: MutablePersistentEntity
Adds an Association to the entity.

Specified by:
addAssociation in interface MutablePersistentEntity<T,P extends PersistentProperty<P>>

getPersistentProperty

public P getPersistentProperty(String name)
Description copied from interface: PersistentEntity
Obtains a PersistentProperty instance by name

Specified by:
getPersistentProperty in interface PersistentEntity<T,P extends PersistentProperty<P>>
Parameters:
name - The name of the property
Returns:
The PersistentProperty or null if it doesn't exist

getType

public Class<T> getType()
Specified by:
getType in interface PersistentEntity<T,P extends PersistentProperty<P>>
Returns:
The underlying Java class for this entity

getTypeInformation

public TypeInformation<T> getTypeInformation()
Specified by:
getTypeInformation in interface PersistentEntity<T,P extends PersistentProperty<P>>

getPersistentPropertyNames

public Collection<String> getPersistentPropertyNames()
Description copied from interface: PersistentEntity
A list of property names

Specified by:
getPersistentPropertyNames in interface PersistentEntity<T,P extends PersistentProperty<P>>
Returns:
A List of strings

doWithProperties

public void doWithProperties(PropertyHandler<P> handler)
Specified by:
doWithProperties in interface PersistentEntity<T,P extends PersistentProperty<P>>

doWithAssociations

public void doWithAssociations(AssociationHandler<P> handler)
Specified by:
doWithAssociations in interface PersistentEntity<T,P extends PersistentProperty<P>>

verify

public void verify()
Description copied from interface: MutablePersistentEntity
Callback method to trigger validation of the PersistentEntity. As MutablePersistentEntity is not immutable there might be some verification steps necessary after the object has reached is final state.

Specified by:
verify in interface MutablePersistentEntity<T,P extends PersistentProperty<P>>

Spring Data Commons

Copyright © 2011. All Rights Reserved.