org.graffiti.plugin.view.interactive.slots
Class MapSlot<K,V>

java.lang.Object
  extended by org.graffiti.plugin.view.interactive.Slot<Map<K,V>>
      extended by org.graffiti.plugin.view.interactive.slots.MapSlot<K,V>
Type Parameters:
K - the type of keys to be maintained by accepted maps.
V - the type of values to be mapped by accepted maps.

public class MapSlot<K,V>
extends Slot<Map<K,V>>

Slot of type Map. The intention of this class is to provide an acceptsValue(Object) method that is strictly type safe despite of generic type erasure.

Version:
$Revision$ $Date$
Author:
Andreas Gleißner

Field Summary
 
Fields inherited from class org.graffiti.plugin.view.interactive.Slot
defaultValue, type
 
Constructor Summary
MapSlot(String id, Class<K> keyType, Class<V> valueType)
          Constructs a MapSlot.
 
Method Summary
 boolean acceptsValue(Object value)
          Returns whether the specified value may be assigned to this slot.
 
Methods inherited from class org.graffiti.plugin.view.interactive.Slot
acceptsNull, create, create, createDefaultPreferences, createListSlot, createMapSlot, createSetSlot, equals, getBuilder, getDefaultValue, getDescription, getId, getName, getType, hashCode, loadValue, saveValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapSlot

public MapSlot(String id,
               Class<K> keyType,
               Class<V> valueType)
Constructs a MapSlot.

Parameters:
id - the id of the slot.
keyType - the Class object modeling the type of keys to be maintained by accepted maps.
valueType - the Class object modeling the type of keys to be maintained by accepted maps.
Method Detail

acceptsValue

public boolean acceptsValue(Object value)
Returns whether the specified value may be assigned to this slot. If one tries to assign an unsupported value to a slot, SlotAssignmentException may be thrown. At least values, that are not assignment-compatible with the slot type, and null, if Slot.acceptsNull() returns false, are not accepted. This implementation checks both if the specified value is a Map and if each of the keys and values contained in the specified map is an instance of the desired type.

Overrides:
acceptsValue in class Slot<Map<K,V>>
Parameters:
value - the value in question.
Returns:
true, if the specified value may be assigned to this slot.
See Also:
Slot.acceptsNull(), SlotMap.put(Slot, Object), SlotMap.put(String, Object)


Generated at 2012-05-30 11:00:36 PM CEST