org.spicefactory.pimento.property
Class MapHandler

java.lang.Object
  extended by org.spicefactory.pimento.property.AbstractAssociationHandler
      extended by org.spicefactory.pimento.property.AbstractCollectionHandler
          extended by org.spicefactory.pimento.property.AbstractUnindexedCollectionHandler
              extended by org.spicefactory.pimento.property.MapHandler
All Implemented Interfaces:
PropertyHandler

public class MapHandler
extends AbstractUnindexedCollectionHandler

Manages a Map property type. Currently only JPA 1.0 style maps are supported. These are maps where persistent entities are used as the values and one property value of the entities as the corresponding key.

Author:
Jens Halm

Field Summary
 
Fields inherited from class org.spicefactory.pimento.property.AbstractAssociationHandler
property
 
Constructor Summary
MapHandler()
          Creates a new instance.
 
Method Summary
protected  void applyCollectionUpdate(Object entity, CollectionUpdate update, Property property)
          Applies the specified collection update to the property of the given entity.
protected  Object createFullCollectionFromSnapshots(List<EntitySnapshot> snapshots, SnapshotDecoder decoder)
          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.
 ManagedProperty getKeyProperty()
          Return the property of the associated entity that will be used as the Maps key.
 void setAssociationModel(TypeHierarchy associationModel)
          Sets the type hierarchy for the polymorphic association.
 void setKeyProperty(ManagedProperty keyProperty)
          Sets the property of the associated entity that will be used as the Maps key.
 
Methods inherited from class org.spicefactory.pimento.property.AbstractUnindexedCollectionHandler
createCollectionUpdate, prepareValueFromSnapshot, setValue
 
Methods inherited from class org.spicefactory.pimento.property.AbstractCollectionHandler
addSupportedInterface, createCollection, getValueForSnapshot
 
Methods inherited from class org.spicefactory.pimento.property.AbstractAssociationHandler
entityForInstance, entityForSnapshot, equals, getAssociationModel, getFetchPlan, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapHandler

public MapHandler()
Creates a new instance.

Method Detail

getKeyProperty

public ManagedProperty getKeyProperty()
Return the property of the associated entity that will be used as the Maps key.

Returns:
the property of the associated entity that will be used as the Maps key

setKeyProperty

public void setKeyProperty(ManagedProperty keyProperty)
Sets the property of the associated entity that will be used as the Maps key.

Parameters:
keyProperty - the property of the associated entity that will be used as the Maps key

getCollection

protected Collection<?> getCollection(Object value)
Description copied from class: AbstractCollectionHandler
Returns the collection that should be used for creating a collection snapshot.

Overrides:
getCollection in class AbstractCollectionHandler
Parameters:
value - the original collection value
Returns:
the collection value the snapshot should be created from.

createFullCollectionFromSnapshots

protected Object createFullCollectionFromSnapshots(List<EntitySnapshot> snapshots,
                                                   SnapshotDecoder decoder)
Description copied from class: AbstractCollectionHandler
Creates and returns a collection of entities from the specified list of snapshots. The type of the returned collection may vary between different subclasses.

Overrides:
createFullCollectionFromSnapshots in class AbstractCollectionHandler
Parameters:
snapshots - the list of snapshots to assemble to entities
decoder - the decoder to use for the specified snapshots
Returns:
a collection of entities created from the specified list of snapshots

applyCollectionUpdate

protected void applyCollectionUpdate(Object entity,
                                     CollectionUpdate update,
                                     Property property)
Description copied from class: AbstractUnindexedCollectionHandler
Applies the specified collection update to the property of the given entity.

Overrides:
applyCollectionUpdate in class AbstractUnindexedCollectionHandler
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

setAssociationModel

public void setAssociationModel(TypeHierarchy associationModel)
Description copied from class: AbstractAssociationHandler
Sets the type hierarchy for the polymorphic association.

Overrides:
setAssociationModel in class AbstractAssociationHandler
Parameters:
associationModel - the type hierarchy for the polymorphic association