org.spicefactory.pimento.type
Class AbstractAssociationType

java.lang.Object
  extended by org.spicefactory.pimento.type.AbstractAssociationType
All Implemented Interfaces:
PropertyType
Direct Known Subclasses:
AbstractCollectionType, AssociationType

public abstract class AbstractAssociationType
extends Object
implements PropertyType

Base class for property types that represent associations to other entities.

Author:
Jens Halm

Constructor Summary
AbstractAssociationType()
           
 
Method Summary
protected  boolean equals(EntitySnapshot newValue, Object oldValue, IoContext context)
          Determines whether the specified snapshot represents the given entity.
 EntityMetadata getAssociationMetadata()
          Returns the entity metadata for the associated entity.
protected  FetchPlan getFetchPlan(FetchMode fetchMode)
          Returns the FetchPlan for the specified FetchMode.
protected  EntityMetadata getMetadataForEntity(IoContext context, Object entity)
          Returns the metadata for the specified entity.
protected  EntityMetadata getMetadataForSnapshot(IoContext context, EntitySnapshot snapshot)
          Returns the metadata for the specified entity snapshot.
 void setAssociationMetadata(EntityMetadata entityMetadata)
          Sets the entity metadata for the associated entity.
 void setValue(Object entity, Object value, Property property)
          Sets the specified property value of the given entity.
protected  boolean useLazyMode(Object entity, FetchMode fetchMode, IoContext context)
          Checks whether the specified entity should be lazily fetched.
 
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.type.PropertyType
getValueForSnapshot, prepareValueFromSnapshot
 

Constructor Detail

AbstractAssociationType

public AbstractAssociationType()
Method Detail

getAssociationMetadata

public EntityMetadata getAssociationMetadata()
Returns the entity metadata for the associated entity. May represent a base class for a polymorphic association.

Returns:
the entity metadata for the associated entity

setAssociationMetadata

public void setAssociationMetadata(EntityMetadata entityMetadata)
Sets the entity metadata for the associated entity.

Parameters:
entityMetadata - the entity metadata for the associated entity

setValue

public void setValue(Object entity,
                     Object value,
                     Property property)
Description copied from interface: PropertyType
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 PropertyType
Parameters:
entity - the entity to set the property for
value - the new value for the property
property - the property to set

getMetadataForEntity

protected EntityMetadata getMetadataForEntity(IoContext context,
                                              Object entity)
Returns the metadata for the specified entity.

Parameters:
context - the active IoContext
entity - the entity to return the metadata for
Returns:
the metadata for the specified entity
Throws:
IllegalArgumentException - if the entity does not correspond to the entity type mapped by this property

getMetadataForSnapshot

protected EntityMetadata getMetadataForSnapshot(IoContext context,
                                                EntitySnapshot snapshot)
Returns the metadata for the specified entity snapshot.

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

useLazyMode

protected boolean useLazyMode(Object entity,
                              FetchMode fetchMode,
                              IoContext context)
Checks whether the specified entity should be lazily fetched.

Parameters:
entity - the entity to check
fetchMode - the fetch mode for the specified entity
context - the active IoContext
Returns:
true if the specified entity should be lazily fetched

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,
                         IoContext context)
Determines whether the specified snapshot represents the given entity.

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