Packageorg.as3collections.maps
Classpublic class TypedMap
InheritanceTypedMap Inheritance Object
Implements IMap
Subclasses TypedListMap

TypedMap works as a wrapper for a map. It stores the wrapMap constructor's argument in the wrappedMap variable. So every method call to this class is forwarded to the wrappedMap object. The methods that need to be checked for the type of the keys and values are previously validated with the validateKeyType, validateValueType or validateMap method before forward the call. If the type of a key or value requested to be inserted to this map is incompatible with the type of the map a org.as3coreaddendum.errors.ClassCastError is thrown. The calls that are forwarded to the wrappedMap returns the return of the wrappedMap call.

TypedMap does not allow null keys or values.

View the examples

See also

MapUtil.getTypedMap()


Public Properties
 PropertyDefined By
  allKeysEquatable : Boolean
[read-only] Indicates whether all keys in this map implements org.as3coreaddendum.system.IEquatable interface.
TypedMap
  allValuesEquatable : Boolean
[read-only] Indicates whether all values in this map implements org.as3coreaddendum.system.IEquatable interface.
TypedMap
  typeKeys : *
[read-only] Defines the acceptable type of the keys by this map.
TypedMap
  typeValues : *
[read-only] Defines the acceptable type of the values by this map.
TypedMap
Public Methods
 MethodDefined By
  
TypedMap(wrapMap:IMap, typeKeys:*, typeValues:*)
Constructor, creates a new TypedMap object.
TypedMap
  
clear():void
Forwards the call to wrappedMap.clear.
TypedMap
  
clone():*
Creates and return a new TypedMap object with the clone of the wrappedMap object.
TypedMap
  
containsKey(key:*):Boolean
Forwards the call to wrappedMap.containsKey.
TypedMap
  
containsValue(value:*):Boolean
Forwards the call to wrappedMap.containsValue.
TypedMap
  
Forwards the call to wrappedMap.entryCollection.
TypedMap
  
equals(other:*):Boolean
This method uses MapUtil.equalNotConsideringOrder or MapUtil.equalConsideringOrder method to perform equality, sending this map and other argument.
TypedMap
  
Forwards the call to wrappedMap.getKeys.
TypedMap
  
getValue(key:*):*
Forwards the call to wrappedMap.getValue.
TypedMap
  
Forwards the call to wrappedMap.getValues.
TypedMap
  
isEmpty():Boolean
Forwards the call to wrappedMap.isEmpty.
TypedMap
  
Forwards the call to wrappedMap.iterator.
TypedMap
  
put(key:*, value:*):*
The key and value are validated with the validateKeyType and validateValueType methods to be forwarded to wrappedMap.put.
TypedMap
  
putAll(map:IMap):void
The map is validated with the validateMap method to be forwarded to wrappedMap.putAll.
TypedMap
  
putAllByObject(o:Object):void
The objects is validated to be forwarded to wrappedMap.putAllByObject.
TypedMap
  
The entry is validated with the validateKeyType and validateValueType methods to be forwarded to wrappedMap.putEntry.
TypedMap
  
remove(key:*):*
Forwards the call to wrappedMap.remove.
TypedMap
  
removeAll(keys:ICollection):Boolean
Forwards the call to wrappedMap.removeAll.
TypedMap
  
retainAll(keys:ICollection):Boolean
Forwards the call to wrappedMap.retainAll.
TypedMap
  
size():int
Forwards the call to wrappedMap.size.
TypedMap
  
toString():String
Returns the string representation of this instance.
TypedMap
Property Detail
allKeysEquatableproperty
allKeysEquatable:Boolean  [read-only]

Indicates whether all keys in this map implements org.as3coreaddendum.system.IEquatable interface.


Implementation
    public function get allKeysEquatable():Boolean
allValuesEquatableproperty 
allValuesEquatable:Boolean  [read-only]

Indicates whether all values in this map implements org.as3coreaddendum.system.IEquatable interface.


Implementation
    public function get allValuesEquatable():Boolean
typeKeysproperty 
typeKeys:*  [read-only]

Defines the acceptable type of the keys by this map.


Implementation
    public function get typeKeys():*
typeValuesproperty 
typeValues:*  [read-only]

Defines the acceptable type of the values by this map.


Implementation
    public function get typeValues():*
Constructor Detail
TypedMap()Constructor
public function TypedMap(wrapMap:IMap, typeKeys:*, typeValues:*)

Constructor, creates a new TypedMap object.

Parameters
wrapMap:IMap — the target map to wrap.
 
typeKeys:* — the type of the keys allowed by this map.
 
typeValues:* — the type of the values allowed by this map.

Throws
ArgumentError — if the wrapMap argument is null.
 
ArgumentError — if the typeKeys argument is null.
 
ArgumentError — if the typeValues argument is null.
 
org.as3coreaddendum.errors:ClassCastError — if the types of one or more keys or values in the wrapMap argument are incompatible with the typeKeys or typeValues argument.
Method Detail
clear()method
public function clear():void

Forwards the call to wrappedMap.clear.

clone()method 
public function clone():*

Creates and return a new TypedMap object with the clone of the wrappedMap object.

Returns
* — a new TypedMap object with the clone of the wrappedMap object.
containsKey()method 
public function containsKey(key:*):Boolean

Forwards the call to wrappedMap.containsKey.

Parameters

key:*

Returns
Boolean — the return of the call wrappedMap.containsKey.
containsValue()method 
public function containsValue(value:*):Boolean

Forwards the call to wrappedMap.containsValue.

Parameters

value:*

Returns
Boolean — the return of the call wrappedMap.containsValue.
entryCollection()method 
public function entryCollection():ICollection

Forwards the call to wrappedMap.entryCollection.

Returns
ICollection
equals()method 
public function equals(other:*):Boolean

This method uses MapUtil.equalNotConsideringOrder or MapUtil.equalConsideringOrder method to perform equality, sending this map and other argument.

If wrappedMap is of type AbstractListMap then MapUtil.equalConsideringOrder method is used. Otherwise MapUtil.equalNotConsideringOrder method is used.

Parameters

other:* — the object to be compared for equality.

Returns
Booleantrue if the arbitrary evaluation considers the objects equal.

See also

getKeys()method 
public function getKeys():ICollection

Forwards the call to wrappedMap.getKeys.

Returns
ICollection
getValue()method 
public function getValue(key:*):*

Forwards the call to wrappedMap.getValue.

Parameters

key:*

Returns
*
getValues()method 
public function getValues():ICollection

Forwards the call to wrappedMap.getValues.

Returns
ICollection
isEmpty()method 
public function isEmpty():Boolean

Forwards the call to wrappedMap.isEmpty.

Returns
Boolean
iterator()method 
public function iterator():IIterator

Forwards the call to wrappedMap.iterator.

Returns
IIterator
put()method 
public function put(key:*, value:*):*

The key and value are validated with the validateKeyType and validateValueType methods to be forwarded to wrappedMap.put.

Parameters

key:* — key with which the specified value is to be associated.
 
value:* — value to be associated with the specified key.

Returns
* — the return of the call wrappedMap.put.

Throws
org.as3coreaddendum.errors:ClassCastError — if the type of the specified key or value is incompatible with this map.
putAll()method 
public function putAll(map:IMap):void

The map is validated with the validateMap method to be forwarded to wrappedMap.putAll.

Parameters

map:IMap

putAllByObject()method 
public function putAllByObject(o:Object):void

The objects is validated to be forwarded to wrappedMap.putAllByObject.

Parameters

o:Object

putEntry()method 
public function putEntry(entry:IMapEntry):*

The entry is validated with the validateKeyType and validateValueType methods to be forwarded to wrappedMap.putEntry.

Parameters

entry:IMapEntry

Returns
*
remove()method 
public function remove(key:*):*

Forwards the call to wrappedMap.remove.

Parameters

key:*

Returns
*
removeAll()method 
public function removeAll(keys:ICollection):Boolean

Forwards the call to wrappedMap.removeAll.

Parameters

keys:ICollection

Returns
Boolean
retainAll()method 
public function retainAll(keys:ICollection):Boolean

Forwards the call to wrappedMap.retainAll.

Parameters

keys:ICollection

Returns
Boolean
size()method 
public function size():int

Forwards the call to wrappedMap.size.

Returns
int
toString()method 
public function toString():String

Returns the string representation of this instance.

Returns
String — the string representation of this instance.
Examples
     import org.as3collections.IMap;
     import org.as3collections.maps.ArrayListMap;
     import org.as3collections.maps.TypedMap;
     
     var map1:IMap = new ArrayListMap();
     
     map1.put("e", 1)            // null
     map1.put("d", 2)            // null
     map1.put("c", 3)            // null
     map1.put("b", 4)            // null
     map1.put("a", 5)            // null
     
     map1                        // {e=1,d=2,c=3,b=4,a=5}
     map1.size()                 // 5
     
     var map2:IMap = new TypedMap(map1, String, Number); // you can use this way
     
     //var map2:IMap = MapUtil.getTypedMap(map1, String, Number); // or you can use this way
     
     map2                        // {e=1,d=2,c=3,b=4,a=5}
     map2.size()                 // 5
     
     map2.equals(map1)           // false
     
     map2.put("f", 6)            // null
     map2                        // {e=1,d=2,c=3,b=4,a=5,f=6}
     map2.size()                 // 6
     
     map2.put("g", "h")          // ClassCastError: Invalid value type. value: h | type: String | expected value type: Number
     map2.put(7, 8)              // ClassCastError: Invalid key type. key: 7 | type: int | expected key type: String