Class GroupByMap<K,E>
- java.lang.Object
-
- ch.systemsx.cisd.openbis.generic.shared.basic.utils.GroupByMap<K,E>
-
public class GroupByMap<K,E> extends java.lang.Object
A map which groups all elements added at the same key.
-
-
Constructor Summary
Constructors Constructor Description GroupByMap(IGroupKeyExtractor<K,E> extractor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(E row)
Adds a new row.static <K,E>
GroupByMap<K,E>create(java.lang.Iterable<? extends E> rows, IGroupKeyExtractor<K,E> extractor)
Creates a map for the specified rows with a given key extractor.java.util.Set<K>
getKeys()
java.util.Map<K,java.util.List<E>>
getMap()
java.util.List<E>
getOrDie(K key)
Returns all rows added at the specified key.java.util.List<E>
tryGet(K key)
Returns all rows added at the specified key.
-
-
-
Constructor Detail
-
GroupByMap
public GroupByMap(IGroupKeyExtractor<K,E> extractor)
- Parameters:
extractor
- computes a key for the row
-
-
Method Detail
-
create
public static <K,E> GroupByMap<K,E> create(java.lang.Iterable<? extends E> rows, IGroupKeyExtractor<K,E> extractor)
Creates a map for the specified rows with a given key extractor.
-
add
public void add(E row)
Adds a new row.
-
getOrDie
public java.util.List<E> getOrDie(K key)
Returns all rows added at the specified key.- Throws:
java.lang.IllegalStateException
- if the key is not in the map
-
getKeys
public java.util.Set<K> getKeys()
- Returns:
- all available keys
-
-