org.spicefactory.pimento.property
Class AbstractAssociationHandler

java.lang.Object
  extended by org.spicefactory.pimento.property.AbstractAssociationHandler
All Implemented Interfaces:
PropertyHandler
Direct Known Subclasses:
AbstractCollectionHandler, AssociationHandler

public abstract class AbstractAssociationHandler
extends Object
implements PropertyHandler

Base class for property handlers that manage associations to other entities.

Author:
Jens Halm

Field Summary
protected  Property property
           
 
Constructor Summary
AbstractAssociationHandler()
           
 
Method Summary
protected  Entity entityForInstance(Object instance)
          Returns the entity metamodel for the specified entity.
protected  Entity entityForSnapshot(EntitySnapshot snapshot)
          Returns the entity metamodel for the specified snapshot.
protected  boolean equals(EntitySnapshot newValue, Object oldValue)
          Determines whether the specified snapshot represents the given entity.
 TypeHierarchy getAssociationModel()
          Returns the type hierarchy for the polymorphic association.
protected  FetchPlan getFetchPlan(FetchMode fetchMode)
          Returns the FetchPlan for the specified FetchMode.
 void init(Property property)
           
 void setAssociationModel(TypeHierarchy associationModel)
          Sets the type hierarchy for the polymorphic association.
 void setValue(Object entity, Object value)
          Sets the specified property value of the given entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.spicefactory.pimento.property.PropertyHandler
getValueForSnapshot, prepareValueFromSnapshot
 

Field Detail

property

protected Property property
Constructor Detail

AbstractAssociationHandler

public AbstractAssociationHandler()
Method Detail

init

public void init(Property property)
Specified by:
init in interface PropertyHandler

getAssociationModel

public TypeHierarchy getAssociationModel()
Returns the type hierarchy for the polymorphic association.

Returns:
the type hierarchy for the polymorphic association

setAssociationModel

public void setAssociationModel(TypeHierarchy associationModel)
Sets the type hierarchy for the polymorphic association.

Parameters:
associationModel - the type hierarchy for the polymorphic association

setValue

public void setValue(Object entity,
                     Object value)
Description copied from interface: PropertyHandler
Sets the specified property value of the given entity. This method can safely assume that the value has been property prepared (possibly converted) with the prepareValueFromSnapshot method of this class before this method gets invoked.

Specified by:
setValue in interface PropertyHandler
Parameters:
entity - the entity to set the property for
value - the new value for the property

entityForInstance

protected Entity entityForInstance(Object instance)
Returns the entity metamodel for the specified entity.

Parameters:
instance - the entity to return the metamodel for
Returns:
the metamodel for the specified entity
Throws:
IllegalArgumentException - if the instance type does not correspond to the entity type mapped by this property

entityForSnapshot

protected Entity entityForSnapshot(EntitySnapshot snapshot)
Returns the entity metamodel for the specified snapshot.

Parameters:
snapshot - the snapshot to return the entity metamodel for
Returns:
the entity metamodel for the specified snapshot
Throws:
IllegalArgumentException - if the snapshot does not correspond to the entity type mapped by this property

getFetchPlan

protected FetchPlan getFetchPlan(FetchMode fetchMode)
Returns the FetchPlan for the specified FetchMode.

Parameters:
fetchMode - the FetchMode to return the FetchPlan for
Returns:
the FetchPlan for the specified FetchMode

equals

protected boolean equals(EntitySnapshot newValue,
                         Object oldValue)
Determines whether the specified snapshot represents the given entity.

Parameters:
newValue - the snapshot to compare
oldValue - the entity to compare
Returns:
true if the specified snapshot represents the given entity