org.spicefactory.pimento.type
Class AbstractUnindexedCollectionType

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

public abstract class AbstractUnindexedCollectionType
extends AbstractCollectionType

Base class for property types that represent unindexed collections.

Author:
Jens Halm

Constructor Summary
AbstractUnindexedCollectionType()
           
 
Method Summary
protected
<T> void
addSupportedInterface(Class<T> collectionInterface, Class<? extends T> implementation)
          Adds an interface type supported by this PropertyType.
protected  void applyCollectionUpdate(Object entity, CollectionUpdate update, Property property)
          Applies the specified collection update to the property of the given entity.
protected  Object createCollection(Class<?> type)
          Creates an instance for the specified collection type.
protected  CollectionUpdate createCollectionUpdate(CollectionChangeSet changeSet, IoContext context)
          Creates a CollectionUpdate instance from the specified change set.
 Object prepareValueFromSnapshot(Object entity, Object value, Property property, IoContext context, boolean createChangeSet)
          Prepares the specified property value, performing all necessary conversions, but without actually applying it to the specified entity.
 void setValue(Object entity, Object value, Property property)
          Sets the specified property value of the given entity.
 
Methods inherited from class org.spicefactory.pimento.type.AbstractCollectionType
createFullCollectionFromSnapshots, getCollection, getValueForSnapshot
 
Methods inherited from class org.spicefactory.pimento.type.AbstractAssociationType
equals, getAssociationMetadata, getFetchPlan, getMetadataForEntity, getMetadataForSnapshot, setAssociationMetadata, useLazyMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractUnindexedCollectionType

public AbstractUnindexedCollectionType()
Method Detail

addSupportedInterface

protected <T> void addSupportedInterface(Class<T> collectionInterface,
                                         Class<? extends T> implementation)
Adds an interface type supported by this PropertyType.

Parameters:
collectionInterface - the supported interface type to add
implementation - the default implementation to use when creating instances of the supported type

prepareValueFromSnapshot

public Object prepareValueFromSnapshot(Object entity,
                                       Object value,
                                       Property property,
                                       IoContext context,
                                       boolean createChangeSet)
Description copied from interface: PropertyType
Prepares the specified property value, performing all necessary conversions, but without actually applying it to the specified entity. The prepared values will be collected in a EntityUpdate instance which gets passed to any configured interceptors before the property is applied with the setValue method of this class.

Parameters:
entity - the entity to prepare the property for
value - the new value for the property
property - the property to prepare
context - the active IoContext
createChangeSet - whether a change set is being created
Returns:
the (possibly converted) value of the property as it will later be applied to the entity.

createCollectionUpdate

protected CollectionUpdate createCollectionUpdate(CollectionChangeSet changeSet,
                                                  IoContext context)
Creates a CollectionUpdate instance from the specified change set. CollectionUpdate instances get passed to the configured interceptors before the change set is applied with applyCollectionUpdate. While the specified change set contains entity snapshots the returned CollectionUpdate must contain the corresponding persistent entities.

Parameters:
changeSet - the change set to convert
context - the active IoContext
Returns:
a CollectionUpdate instance created from the specified change set

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
Overrides:
setValue in class AbstractAssociationType
Parameters:
entity - the entity to set the property for
value - the new value for the property
property - the property to set

applyCollectionUpdate

protected void applyCollectionUpdate(Object entity,
                                     CollectionUpdate update,
                                     Property property)
Applies the specified collection update to the property of the given entity.

Parameters:
entity - the entity the update should be applied to
update - the collection update to apply
property - the property of the entity that the update should be applied to

createCollection

protected Object createCollection(Class<?> type)
Creates an instance for the specified collection type. The given type might be an interface type, in that case it should be mapped to the default implementation as specified with addSupportedInterface.

Parameters:
type - the collection type to create an instance for
Returns:
an instance for the specified collection type