public final class MutableContextSet extends Object implements ContextSet
ContextSet.| Constructor and Description |
|---|
MutableContextSet() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Map.Entry<String,String> entry)
Adds a context to this set.
|
void |
add(String key,
String value)
Adds a context to this set.
|
void |
addAll(ContextSet contextSet)
Adds of of the contexts in another
ContextSet to this set. |
void |
addAll(Iterable<? extends Map.Entry<String,String>> iterable)
Adds the contexts contained in the given
Iterable to this set. |
void |
addAll(Map<String,String> map)
Adds the contexts contained in the given
Map to this set. |
void |
addAll(Multimap<String,String> multimap)
Adds the contexts contained in the given
Multimap to this set. |
protected SetMultimap<String,String> |
backing() |
void |
clear()
Removes all contexts from the set.
|
boolean |
containsKey(String key)
Returns if the
ContextSet contains at least one value for the
given key. |
protected void |
copyTo(SetMultimap<String,String> other) |
static MutableContextSet |
create()
Creates a new empty MutableContextSet.
|
boolean |
equals(Object o) |
static MutableContextSet |
fromEntries(Iterable<? extends Map.Entry<String,String>> iterable)
|
static MutableContextSet |
fromMap(Map<String,String> map)
Creates a
MutableContextSet from an existing Map. |
static MutableContextSet |
fromMultimap(Multimap<String,String> multimap)
Creates a
MutableContextSet from an existing Multimap. |
static MutableContextSet |
fromSet(ContextSet contextSet)
Creates a new
MutableContextSet from an existing Set. |
Set<String> |
getValues(String key)
Returns a
Set of the values mapped to the given key. |
boolean |
has(String key,
String value)
Returns if the
ContextSet contains a given context pairing. |
int |
hashCode() |
boolean |
isEmpty()
Returns if the
ContextSet is empty. |
boolean |
isImmutable()
Gets if this
ContextSet is immutable. |
Iterator<Map.Entry<String,String>> |
iterator()
Returns an
Iterator over each of the context pairs in this set. |
ImmutableContextSet |
makeImmutable()
Returns an immutable representation of this
ContextSet. |
MutableContextSet |
mutableCopy()
Creates a mutable copy of this
ContextSet. |
static MutableContextSet |
of(String key1,
String value1,
String key2,
String value2)
Creates a
MutableContextSet from two context pairs. |
void |
remove(String key,
String value)
Removes a context from this set.
|
void |
removeAll(String key)
Removes all contexts from this set with the given key.
|
static MutableContextSet |
singleton(String key,
String value)
Creates a
MutableContextSet from a context pair. |
int |
size()
Gets the number of context pairs in the
ContextSet. |
Spliterator<Map.Entry<String,String>> |
spliterator() |
Map<String,String> |
toMap()
Deprecated.
|
Multimap<String,String> |
toMultimap()
Returns a
Multimap representing the current state of this
ContextSet. |
Set<Map.Entry<String,String>> |
toSet()
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcontainsKey, empty, getAnyValue, getValues, has, has, isEmpty, isSatisfiedBy, size@Nonnull public static MutableContextSet singleton(@Nonnull String key, @Nonnull String value)
MutableContextSet from a context pair.singleton in interface ContextSetkey - the keyvalue - the valueNullPointerException - if key or value is null@Nonnull public static MutableContextSet of(@Nonnull String key1, @Nonnull String value1, @Nonnull String key2, @Nonnull String value2)
MutableContextSet from two context pairs.of in interface ContextSetkey1 - the first keyvalue1 - the first valuekey2 - the second keyvalue2 - the second valueNullPointerException - if any of the keys or values are null@Nonnull public static MutableContextSet fromEntries(@Nonnull Iterable<? extends Map.Entry<String,String>> iterable)
fromEntries in interface ContextSetiterable - the iterable to copy fromNullPointerException - if the iterable is null@Nonnull public static MutableContextSet fromMap(@Nonnull Map<String,String> map)
MutableContextSet from an existing Map.fromMap in interface ContextSetmap - the map to copy fromNullPointerException - if the map is null@Nonnull public static MutableContextSet fromMultimap(@Nonnull Multimap<String,String> multimap)
MutableContextSet from an existing Multimap.fromMultimap in interface ContextSetmultimap - the multimap to copy fromNullPointerException - if the multimap is null@Nonnull public static MutableContextSet fromSet(@Nonnull ContextSet contextSet)
MutableContextSet from an existing Set.
Only really useful for converting between mutable and immutable types.
fromSet in interface ContextSetcontextSet - the context set to copy fromNullPointerException - if contextSet is null@Nonnull public static MutableContextSet create()
protected SetMultimap<String,String> backing()
protected void copyTo(SetMultimap<String,String> other)
public boolean isImmutable()
ContextSetContextSet is immutable.
The state of immutable instances will never change.
isImmutable in interface ContextSet@Nonnull public ImmutableContextSet makeImmutable()
ContextSetContextSet.
If the set is already immutable, the same object will be returned. If the set is mutable, an immutable copy will be made.
makeImmutable in interface ContextSet@Nonnull public MutableContextSet mutableCopy()
ContextSetContextSet.
A new copy is returned regardless of the
mutability of this set.
mutableCopy in interface ContextSet@Nonnull public Set<Map.Entry<String,String>> toSet()
ContextSetSet of Map.Entrys representing the current
state of this ContextSet.
The returned set is immutable, and is a copy of the current set. (will not update live)
toSet in interface ContextSet@Nonnull @Deprecated public Map<String,String> toMap()
ContextSetMap loosely representing the current state of
this ContextSet.
The returned map is immutable, and is a copy of the current set. (will not update live)
As a single context key can be mapped to multiple values, this method may not be a true representation of the set.
If you need a representation of the set in a Java collection instance,
use ContextSet.toSet() or ContextSet.toMultimap() followed by
Multimap.asMap().
toMap in interface ContextSet@Nonnull public Multimap<String,String> toMultimap()
ContextSetMultimap representing the current state of this
ContextSet.
The returned multimap is immutable, and is a copy of the current set. (will not update live)
toMultimap in interface ContextSet@Nonnull public Iterator<Map.Entry<String,String>> iterator()
ContextSetIterator over each of the context pairs in this set.
The returned iterator represents the state of the set at the time of creation. It is not updated as the set changes.
The iterator does not support Iterator.remove() calls.
public Spliterator<Map.Entry<String,String>> spliterator()
spliterator in interface Iterable<Map.Entry<String,String>>public void add(@Nonnull String key, @Nonnull String value)
key - the key to addvalue - the value to addNullPointerException - if the key or value is nullpublic void add(@Nonnull Map.Entry<String,String> entry)
entry - the entry to addNullPointerException - if the entry is nullpublic void addAll(@Nonnull Iterable<? extends Map.Entry<String,String>> iterable)
Iterable to this set.iterable - an iterable of key value context pairsNullPointerException - if iterable is nullpublic void addAll(@Nonnull Map<String,String> map)
Map to this set.map - the map to add fromNullPointerException - if the map is nullpublic void addAll(@Nonnull Multimap<String,String> multimap)
Multimap to this set.multimap - the multimap to add fromNullPointerException - if the map is nullpublic void addAll(@Nonnull ContextSet contextSet)
ContextSet to this set.contextSet - the set to add fromNullPointerException - if the contextSet is nullpublic void remove(@Nonnull String key, @Nonnull String value)
key - the key to removevalue - the value to removeNullPointerException - if the key or value is nullpublic void removeAll(@Nonnull String key)
key - the key to removeNullPointerException - if the key is nullpublic void clear()
public boolean containsKey(@Nonnull String key)
ContextSetContextSet contains at least one value for the
given key.containsKey in interface ContextSetkey - the key to check for@Nonnull public Set<String> getValues(@Nonnull String key)
ContextSetSet of the values mapped to the given key.
The returned set is immutable, and only represents the current state
of the ContextSet. (will not update live)
getValues in interface ContextSetkey - the key to get values forpublic boolean has(@Nonnull String key, @Nonnull String value)
ContextSetContextSet contains a given context pairing.has in interface ContextSetkey - the key to look forvalue - the value to look forpublic boolean isEmpty()
ContextSetContextSet is empty.isEmpty in interface ContextSetpublic int size()
ContextSetContextSet.size in interface ContextSetCopyright © 2018. All rights reserved.