org.spicefactory.pimento.type
Class MapType

java.lang.Object
  extended by org.spicefactory.pimento.type.AbstractAssociationType
      extended by org.spicefactory.pimento.type.AbstractCollectionType
          extended by org.spicefactory.pimento.type.AbstractUnindexedCollectionType
              extended by org.spicefactory.pimento.type.MapType
All Implemented Interfaces:
PropertyAware, PropertyType

public class MapType
extends AbstractUnindexedCollectionType
implements PropertyAware

Represents 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

Constructor Summary
MapType()
          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, 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.
 PropertyMetadata getKeyProperty()
          Return the metadata for the property of the associated entity that will be used as the Maps key.
 void setAssociationMetadata(EntityMetadata entityMetadata)
          Sets the entity metadata for the associated entity.
 void setKeyProperty(PropertyMetadata entityMetadata)
          Sets the metadata for the property of the associated entity that will be used as the Maps key.
 void setProperty(Property property)
          Sets the property that this PropertyType instance is applied to.
 
Methods inherited from class org.spicefactory.pimento.type.AbstractUnindexedCollectionType
addSupportedInterface, createCollection, createCollectionUpdate, prepareValueFromSnapshot, setValue
 
Methods inherited from class org.spicefactory.pimento.type.AbstractCollectionType
getValueForSnapshot
 
Methods inherited from class org.spicefactory.pimento.type.AbstractAssociationType
equals, getAssociationMetadata, getFetchPlan, getMetadataForEntity, getMetadataForSnapshot, useLazyMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapType

public MapType()
Creates a new instance.

Method Detail

getKeyProperty

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

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

setKeyProperty

public void setKeyProperty(PropertyMetadata entityMetadata)
Sets the metadata for the property of the associated entity that will be used as the Maps key.

Parameters:
entityMetadata - the metadata for the property of the associated entity that will be used as the Maps key

getCollection

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

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

createFullCollectionFromSnapshots

protected Object createFullCollectionFromSnapshots(List<EntitySnapshot> snapshots,
                                                   IoContext context)
Description copied from class: AbstractCollectionType
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 AbstractCollectionType
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

applyCollectionUpdate

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

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

setAssociationMetadata

public void setAssociationMetadata(EntityMetadata entityMetadata)
Description copied from class: AbstractAssociationType
Sets the entity metadata for the associated entity.

Overrides:
setAssociationMetadata in class AbstractAssociationType
Parameters:
entityMetadata - the entity metadata for the associated entity

setProperty

public void setProperty(Property property)
Description copied from interface: PropertyAware
Sets the property that this PropertyType instance is applied to.

Specified by:
setProperty in interface PropertyAware
Parameters:
property - the property that this PropertyType instance is applied to