net.sf.molae.pipe.adapt
Class ListAsMap<V>
java.lang.Object
java.util.AbstractMap<K,V>
net.sf.molae.pipe.basic.AbstractMapWithSet<Integer,V>
net.sf.molae.pipe.adapt.ListAsMap<V>
- All Implemented Interfaces:
- Map<Integer,V>
public class ListAsMap<V>
- extends AbstractMapWithSet<Integer,V>
Map view on a list.
The list is seen as a map where the index is the key of each entry.
- Since:
- 2.1
Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
newInstance
public static <V> Map<Integer,V> newInstance(List<V> values,
boolean withNulls)
- Creates a new ListAsMap
- Parameters:
values
- underlying listwithNulls
- if true
all items of the list are incorporated
in the map, if false
only the non-null values.
- Returns:
- map view of the specified list
size
public int size()
- Description copied from class:
AbstractMapWithSet
- Returns the number of mappings in this map.
This implementation uses the iterator to count the elements.
- Specified by:
size
in interface Map<Integer,V>
- Overrides:
size
in class AbstractMapWithSet<Integer,V>
- Returns:
- the number of mappings in this map.
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interface Map<Integer,V>
- Overrides:
containsKey
in class AbstractMap<Integer,V>
get
public V get(Object key)
- Specified by:
get
in interface Map<Integer,V>
- Overrides:
get
in class AbstractMap<Integer,V>
put
public V put(Integer key,
V value)
- Specified by:
put
in interface Map<Integer,V>
- Overrides:
put
in class AbstractMap<Integer,V>
remove
public V remove(Object key)
- Specified by:
remove
in interface Map<Integer,V>
- Overrides:
remove
in class AbstractMap<Integer,V>
clear
public void clear()
- Specified by:
clear
in interface Map<Integer,V>
- Overrides:
clear
in class AbstractMap<Integer,V>
getEntrySetIterator
protected Iterator<Map.Entry<Integer,V>> getEntrySetIterator()
- Description copied from class:
AbstractMapWithSet
- Returns the iterator of the entry set.
- Specified by:
getEntrySetIterator
in class AbstractMapWithSet<Integer,V>
- Returns:
- the iterator of the entry set.
listToMaptransformer
public static final <V> TwoWayTransformer<List<V>,Map<Integer,V>> listToMaptransformer()
- Provides a tranformer that transforms a list into its map view.
Null-values in the base list are not incorporated in the map.
- Returns:
- the transformer