org.springframework.datastore.mapping
Class AbstractPersistentEntity<T>

java.lang.Object
  extended by org.springframework.datastore.mapping.AbstractPersistentEntity<T>
All Implemented Interfaces:
Initializable, PersistentEntity
Direct Known Subclasses:
KeyValuePersistentEntity

public abstract class AbstractPersistentEntity<T>
extends Object
implements PersistentEntity, Initializable

Abstract implementation to be subclasses on a per datastore basis

Since:
1.0

Field Summary
protected  List<Association> associations
           
protected  MappingContext context
           
protected  PersistentProperty identity
           
protected  Class javaClass
           
protected  Set owners
           
protected  List<PersistentProperty> persistentProperties
           
protected  List<String> persistentPropertyNames
           
protected  Map<String,PersistentProperty> propertiesByName
           
 
Constructor Summary
AbstractPersistentEntity(Class javaClass, MappingContext context)
           
 
Method Summary
 boolean equals(Object o)
           
 List<Association> getAssociations()
          A list of the associations for this entity.
 String getDecapitalizedName()
           
 String getDiscriminator()
          The discriminator used when persisting subclasses of an inheritance hierarchy
 PersistentProperty getIdentity()
          Returns the identity of the instance
 Class getJavaClass()
           
 ClassMapping<T> getMapping()
          Defines the mapping between this persistent entity and an external form
 MappingContext getMappingContext()
          Obtains the MappingContext where this PersistentEntity is defined
 String getName()
          The entity name including any package prefix
 PersistentEntity getParentEntity()
          Returns the parent entity of this entity
 List<PersistentProperty> getPersistentProperties()
          A list of properties to be persisted
 List<String> getPersistentPropertyNames()
          A list of property names that a persistent
 PersistentProperty getPropertyByName(String name)
          Obtains a PersistentProperty instance by name
 PersistentEntity getRootEntity()
          Obtains the root entity of an inheritance hierarchy
 int hashCode()
           
 boolean hasProperty(String name, Class type)
          Checks whether an entity has a bean property of the given name and type
 void initialize()
          Call to initialize the object
 boolean isInstance(Object obj)
          Tests whether the given instance is an instance of this persistent entity
 boolean isOwningEntity(PersistentEntity owner)
          Returns whether the specified entity asserts ownership over this entity
 boolean isRoot()
          Whether this entity is a root entity
 Object newInstance()
          Constructs a new instance
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

javaClass

protected Class javaClass

persistentProperties

protected List<PersistentProperty> persistentProperties

associations

protected List<Association> associations

propertiesByName

protected Map<String,PersistentProperty> propertiesByName

context

protected MappingContext context

identity

protected PersistentProperty identity

persistentPropertyNames

protected List<String> persistentPropertyNames

owners

protected Set owners
Constructor Detail

AbstractPersistentEntity

public AbstractPersistentEntity(Class javaClass,
                                MappingContext context)
Method Detail

getMappingContext

public MappingContext getMappingContext()
Description copied from interface: PersistentEntity
Obtains the MappingContext where this PersistentEntity is defined

Specified by:
getMappingContext in interface PersistentEntity
Returns:
The MappingContext instance

initialize

public void initialize()
Description copied from interface: Initializable
Call to initialize the object

Specified by:
initialize in interface Initializable

hasProperty

public boolean hasProperty(String name,
                           Class type)
Description copied from interface: PersistentEntity
Checks whether an entity has a bean property of the given name and type

Specified by:
hasProperty in interface PersistentEntity
Parameters:
name - The name
type - The type
Returns:
True if it does

getParentEntity

public PersistentEntity getParentEntity()
Description copied from interface: PersistentEntity
Returns the parent entity of this entity

Specified by:
getParentEntity in interface PersistentEntity
Returns:
The ParentEntity instance

getDiscriminator

public String getDiscriminator()
Description copied from interface: PersistentEntity
The discriminator used when persisting subclasses of an inheritance hierarchy

Specified by:
getDiscriminator in interface PersistentEntity
Returns:
The discriminator

getRootEntity

public PersistentEntity getRootEntity()
Description copied from interface: PersistentEntity
Obtains the root entity of an inheritance hierarchy

Specified by:
getRootEntity in interface PersistentEntity
Returns:
The root entity

isRoot

public boolean isRoot()
Description copied from interface: PersistentEntity
Whether this entity is a root entity

Specified by:
isRoot in interface PersistentEntity
Returns:
True if it is a root entity

isOwningEntity

public boolean isOwningEntity(PersistentEntity owner)
Description copied from interface: PersistentEntity
Returns whether the specified entity asserts ownership over this entity

Specified by:
isOwningEntity in interface PersistentEntity
Parameters:
owner - The owning entity
Returns:
True if it does own this entity

getDecapitalizedName

public String getDecapitalizedName()
Specified by:
getDecapitalizedName in interface PersistentEntity
Returns:
Returns the name of the class decapitalized form

getPersistentPropertyNames

public List<String> getPersistentPropertyNames()
Description copied from interface: PersistentEntity
A list of property names that a persistent

Specified by:
getPersistentPropertyNames in interface PersistentEntity
Returns:
A List of strings

getMapping

public ClassMapping<T> getMapping()
Description copied from interface: PersistentEntity
Defines the mapping between this persistent entity and an external form

Specified by:
getMapping in interface PersistentEntity
Returns:
The ClassMapping instance

newInstance

public Object newInstance()
Description copied from interface: PersistentEntity
Constructs a new instance

Specified by:
newInstance in interface PersistentEntity
Returns:
The new instnace

getName

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

Specified by:
getName in interface PersistentEntity
Returns:
The entity name

getIdentity

public PersistentProperty getIdentity()
Description copied from interface: PersistentEntity
Returns the identity of the instance

Specified by:
getIdentity in interface PersistentEntity
Returns:
The identity

getJavaClass

public Class getJavaClass()
Specified by:
getJavaClass in interface PersistentEntity
Returns:
The underlying Java class for this entity

isInstance

public boolean isInstance(Object obj)
Description copied from interface: PersistentEntity
Tests whether the given instance is an instance of this persistent entity

Specified by:
isInstance in interface PersistentEntity
Parameters:
obj - The object
Returns:
True if it is

getPersistentProperties

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

Specified by:
getPersistentProperties in interface PersistentEntity
Returns:
A list of PersistentProperty instances

getAssociations

public List<Association> 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
Returns:
A list of associations

getPropertyByName

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

Specified by:
getPropertyByName in interface PersistentEntity
Parameters:
name - The name of the property
Returns:
The PersistentProperty or null if it doesn't exist

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object