K
- the type of the key in a message collector which will use an underlying mapping.V
- the type of the elements in the collection underlying the message collector, or the collection which is a value in the mapping underlying the message collector. It is necessary for the purposes of homogeneity that the collection and the values in the mapping have the same generic type. Where there may be mixed types, Object
can be used. see MessageCollectors see ReasonK
- type of keys supported by this message collector.V
- type of values supported by this message collector.public class MessageCollector<K,V> extends Object
Constructor and Description |
---|
MessageCollector()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(K key, Collection<V> value)
Adds all elements of a value collection against the specified key in the underlying map in the collector.
|
void |
add(K key, V value)
Adds a value against the specified key in the underlying map in the collector.
|
boolean |
add(V e) |
boolean |
addAll(Collection<? extends V> c) |
void |
addAll(Map<? extends K,? extends Collection<V>> m)
Adds mapping from an existing message mapping into this message collector's map.
|
void |
clear()
Clears all messages collected into this message collector.
|
boolean |
contains(K o) |
boolean |
containsKey(K key) |
Collection<V> |
get(K key)
Returns the messages collected against the specified key if the underlying collector is a map.
|
V |
getFirst()
Retrieves the first value from the generic messages collection.
|
V |
getFirst(K key)
Retrieves the first value from the message collector.
|
V |
getFirstMessage()
Returns the first message from the collection or the first message from the map iff there is only one entry in the map.
|
Map<K,Collection<V>> |
getMessageMap()
Returns a read-only view of the messages collected as a mapping.
|
Collection<V> |
getMessages()
Returns a read-only view of the messages collected as a collection.
|
boolean |
isEmpty()
Checks if the message collector contains any messages.
|
Set<K> |
keySet() |
protected Collection<V> |
newMessages()
Returns the underlying
Collection instance to be wrapped by this message collector. |
protected Map<K,Collection<V>> |
newMessagesMap()
Returns the underlying
Map instance to be wrapped by this message collector. |
boolean |
remove(int index) |
Collection<V> |
remove(K key) |
boolean |
removeAll(Collection<?> c) |
boolean |
removeAll(K key, Collection<?> c)
Removes all of this collector's elements that are also contained in the specified collection.
|
boolean |
retainAll(Collection<?> c) |
boolean |
retainAll(K key, Collection<?> c)
Retains only the elements in this collector that are contained in the specified collection.
|
public MessageCollector()
protected Collection<V> newMessages()
Collection
instance to be wrapped by this message collector. The same instantiation is used for the collection objects to be used as values in the mapping.protected Map<K,Collection<V>> newMessagesMap()
Map
instance to be wrapped by this message collector.public final boolean isEmpty()
public final Collection<V> get(K key)
key
- a keypublic final void add(K key, Collection<V> value)
key
- the key to set.value
- the value to set.public final void add(K key, V value)
key
- the key to set.value
- the value to set.public final Map<K,Collection<V>> getMessageMap()
public final Collection<V> getMessages()
public final void addAll(Map<? extends K,? extends Collection<V>> m)
m
- the input map.public final void clear()
public final boolean removeAll(K key, Collection<?> c)
key
- the key used to retrieve the collection value from the underlying map.c
- collection containing elements to be removed from this collector.public final boolean retainAll(K key, Collection<?> c)
key
- the key used to retrieve the collection value from the underlying map.c
- the collection which is to be added as a value in the underlying map.public final V getFirst()
public final V getFirst(K key)
key
is null, retrieves the message from the underlying collection. This is equivalent to calling link getFirst(). Otherwise, reads the first value from the underlying map.key
- the key against which the values are read.public V getFirstMessage()
public final boolean containsKey(K key)
public final Collection<V> remove(K key)
public final boolean contains(K o)
public final boolean add(V e)
public final boolean addAll(Collection<? extends V> c)
public final boolean removeAll(Collection<?> c)
public final boolean retainAll(Collection<?> c)
public final boolean remove(int index)