org.inria.ns.reflex.util
Class EntryMap.Impl

java.lang.Object
  extended by org.inria.ns.reflex.util.EntryMap.Impl
All Implemented Interfaces:
Map, EntryBuilder, EntryMap
Enclosing interface:
EntryMap

public static class EntryMap.Impl
extends Object
implements EntryMap

A default implementation of an entry map.

Author:
Philippe Poulard

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.inria.ns.reflex.util.EntryMap
EntryMap.Impl
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
EntryMap.Impl(EntryBuilder entryBuilder)
          Create a new entry map.
 
Method Summary
 void clear()
          Clear this map.
 boolean containsKey(Object key)
          Indicates whether this map contains the given key.
 boolean containsValue(Object value)
          Indicates whether this map contains the given value.
 Set entrySet()
          Return the set of entries in this map.
 boolean equals(Object o)
          Compares the specified object with this map for equality.
 Object get(Object key)
          Return the entry that has the given key.
 int hashCode()
          Returns the hash code value for this map.
 boolean isEmpty()
          Indicates whether this map contains entries or not.
 Set keySet()
          Return the set of keys of this map.
 Map.Entry newEntry(Object key, Object value)
          Create a new entry ; this method doesn't store the entry in this map, it just creates an entry that this map will accept for storage.
 Object put(Map.Entry entry)
          Store an entry as is in this map.
 Object put(Object key, Object value)
          Store a new entry in this map.
 void putAll(Map map)
          Stored all entries of the given map in this map.
 Object remove(Object key)
          Remove an entry.
 int size()
          Return the number of entries in this map.
 Collection values()
          Return the entries stored in this map.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntryMap.Impl

public EntryMap.Impl(EntryBuilder entryBuilder)
Create a new entry map.

Parameters:
entryBuilder -
Method Detail

newEntry

public Map.Entry newEntry(Object key,
                          Object value)
Create a new entry ; this method doesn't store the entry in this map, it just creates an entry that this map will accept for storage.

Specified by:
newEntry in interface EntryBuilder
Parameters:
key - The entry key.
value - The entry value.
Returns:
The entry built by the relevant entry builder.

clear

public void clear()
Clear this map.

Specified by:
clear in interface Map

containsKey

public boolean containsKey(Object key)
Indicates whether this map contains the given key.

Specified by:
containsKey in interface Map
Parameters:
key - The key to lookup.
Returns:
true if an entry exists with that key, false otherwise.

containsValue

public boolean containsValue(Object value)
Indicates whether this map contains the given value.

Specified by:
containsValue in interface Map
Parameters:
value - The value to lookup. The value should be itself an entry.
Returns:
true if an entry exists with that value, false otherwise.
See Also:
Map.Entry

entrySet

public Set entrySet()
Return the set of entries in this map.

Specified by:
entrySet in interface Map
Returns:
The set of entries.

equals

public boolean equals(Object o)
Compares the specified object with this map for equality.

Specified by:
equals in interface Map
Overrides:
equals in class Object
Parameters:
o - Object to be compared.
Returns:
true if the entries are the same, false otherwise.

get

public Object get(Object key)
Return the entry that has the given key.

Specified by:
get in interface Map
Parameters:
key - The key to lookup.
Returns:
The entry, or null.

hashCode

public int hashCode()
Returns the hash code value for this map.

Specified by:
hashCode in interface Map
Overrides:
hashCode in class Object
Returns:
The hash code of the underlying map.

isEmpty

public boolean isEmpty()
Indicates whether this map contains entries or not.

Specified by:
isEmpty in interface Map
Returns:
true if this map has no entries, false otherwise.

keySet

public Set keySet()
Return the set of keys of this map.

Specified by:
keySet in interface Map
Returns:
The set of keys.

put

public Object put(Map.Entry entry)
Store an entry as is in this map.

The entry stored should be of the type expected (the same than those built by the entry builder). This method doesn't check the compatibility of the entry given with those expected internally.

Specified by:
put in interface EntryMap
Parameters:
entry - The entry to store.
Returns:
The previous entry.
See Also:
EntryBuilder.newEntry(Object, Object)

put

public Object put(Object key,
                  Object value)
Store a new entry in this map.

The entry is created with newEntry(Object, Object). If the value is already an entry, it is wrapped inside the new entry ; if this behaviour is not those expected, the entry can be stored as is with #put(Entry).

Specified by:
put in interface Map
Parameters:
key - The entry key.
value - The entry value.
Returns:
The stored entry.

putAll

public void putAll(Map map)
Stored all entries of the given map in this map.

If the values of the source map are entries, they are stored as is, otherwise the entries are stored.

In both cases, the entries stored should be those of the type expected (the same build by the entry builder). This method doesn't check the compatibility.

Specified by:
putAll in interface Map
Parameters:
map - Mappings to be stored in this map.

remove

public Object remove(Object key)
Remove an entry.

Specified by:
remove in interface Map
Parameters:
key - The key of the entry to remove.
Returns:
The previous entry.

size

public int size()
Return the number of entries in this map.

Specified by:
size in interface Map
Returns:
The size of this map.

values

public Collection values()
Return the entries stored in this map.

Specified by:
values in interface Map
Returns:
The entries stored in this map.