org.spicefactory.pimento.type
Class AbstractCollectionType

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

public abstract class AbstractCollectionType
extends AbstractAssociationType

Base class for property types that represent collections.

Author:
Jens Halm

Constructor Summary
AbstractCollectionType()
           
 
Method Summary
protected  Object createFullCollectionFromSnapshots(List<EntitySnapshot> snapshots, IoContext context)
          Creates and returns a collection of entities from the specified list of snapshots.
protected  Collection<?> getCollection(Object value)
          Returns the collection that should be used for creating a collection snapshot.
 Object getValueForSnapshot(Object entity, Property property, IoContext context, FetchMode fetchMode)
          Reads the specified property from the given entity and returns it in a form suitable for inclusion in an entity snapshot.
 
Methods inherited from class org.spicefactory.pimento.type.AbstractAssociationType
equals, getAssociationMetadata, getFetchPlan, getMetadataForEntity, getMetadataForSnapshot, setAssociationMetadata, setValue, useLazyMode
 
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
prepareValueFromSnapshot
 

Constructor Detail

AbstractCollectionType

public AbstractCollectionType()
Method Detail

getValueForSnapshot

public Object getValueForSnapshot(Object entity,
                                  Property property,
                                  IoContext context,
                                  FetchMode fetchMode)
Description copied from interface: PropertyType
Reads the specified property from the given entity and returns it in a form suitable for inclusion in an entity snapshot. For associations this means that non-null values should be converted to snapshots themselves, using the provided IoContext instance. Simple values could be returned as-is in most cases.

Parameters:
entity - the entity to extract the property value from
property - the property to extract
context - the active IoContext
fetchMode - the fetchMode to use if the property type is an association
Returns:
the current value of the property as a simple value, an entity snapshot or an instance of PropertyState

createFullCollectionFromSnapshots

protected Object createFullCollectionFromSnapshots(List<EntitySnapshot> snapshots,
                                                   IoContext context)
Creates and returns a collection of entities from the specified list of snapshots. The type of the returned collection may vary between different subclasses.

Parameters:
snapshots - the list of snapshots to assemble to entities
context - the active IoContext
Returns:
a collection of entities created from the specified list of snapshots

getCollection

protected Collection<?> getCollection(Object value)
Returns the collection that should be used for creating a collection snapshot.

Parameters:
value - the original collection value
Returns:
the collection value the snapshot should be created from.