Package | org.as3collections.maps |
Class | public class TypedMap |
Inheritance | TypedMap 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.
See also
Property | Defined 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 |
Method | Defined By | ||
---|---|---|---|
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 | ||
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 |
allKeysEquatable | property |
allKeysEquatable:Boolean
[read-only]
Indicates whether all keys in this map implements org.as3coreaddendum.system.IEquatable
interface.
public function get allKeysEquatable():Boolean
allValuesEquatable | property |
allValuesEquatable:Boolean
[read-only]
Indicates whether all values in this map implements org.as3coreaddendum.system.IEquatable
interface.
public function get allValuesEquatable():Boolean
typeKeys | property |
typeKeys:*
[read-only] Defines the acceptable type of the keys by this map.
public function get typeKeys():*
typeValues | property |
typeValues:*
[read-only] Defines the acceptable type of the values by this map.
public function get typeValues():*
TypedMap | () | Constructor |
public function TypedMap(wrapMap:IMap, typeKeys:*, typeValues:*)
Constructor, creates a new TypedMap
object.
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.
|
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.
|
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.
* — 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:* |
Boolean — the return of the call wrappedMap.containsKey .
|
containsValue | () | method |
public function containsValue(value:*):Boolean
Forwards the call to wrappedMap.containsValue
.
Parameters
value:* |
Boolean — the return of the call wrappedMap.containsValue .
|
entryCollection | () | method |
public function entryCollection():ICollection
Forwards the call to wrappedMap.entryCollection
.
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.
|
Boolean — true if the arbitrary evaluation considers the objects equal.
|
See also
getKeys | () | method |
getValue | () | method |
public function getValue(key:*):*
Forwards the call to wrappedMap.getValue
.
Parameters
key:* |
* |
getValues | () | method |
public function getValues():ICollection
Forwards the call to wrappedMap.getValues
.
ICollection —
|
isEmpty | () | method |
public function isEmpty():Boolean
Forwards the call to wrappedMap.isEmpty
.
Boolean —
|
iterator | () | method |
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.
|
* — the return of the call wrappedMap.put .
|
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 |
* |
remove | () | method |
public function remove(key:*):*
Forwards the call to wrappedMap.remove
.
Parameters
key:* |
* |
removeAll | () | method |
public function removeAll(keys:ICollection):Boolean
Forwards the call to wrappedMap.removeAll
.
Parameters
keys:ICollection |
Boolean —
|
retainAll | () | method |
public function retainAll(keys:ICollection):Boolean
Forwards the call to wrappedMap.retainAll
.
Parameters
keys:ICollection |
Boolean —
|
size | () | method |
public function size():int
Forwards the call to wrappedMap.size
.
int —
|
toString | () | method |
public function toString():String
Returns the string representation of this instance.
ReturnsString — the string representation of this instance.
|
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