public final class ImmutableContextSet extends Object implements ContextSet
ContextSet.| Modifier and Type | Class and Description |
|---|---|
static class |
ImmutableContextSet.Builder
A builder for
ImmutableContextSet. |
| Modifier and Type | Method and Description |
|---|---|
protected SetMultimap<String,String> |
backing() |
static @NonNull ImmutableContextSet.Builder |
builder()
Creates an
ImmutableContextSet.Builder. |
boolean |
containsKey(@NonNull String key)
Returns if the
ContextSet contains at least one value for the
given key. |
protected void |
copyTo(SetMultimap<String,String> other) |
static @NonNull ImmutableContextSet |
empty()
Returns an empty
ImmutableContextSet. |
boolean |
equals(Object o) |
static @NonNull ImmutableContextSet |
fromEntries(@NonNull Iterable<? extends Map.Entry<String,String>> iterable)
|
static @NonNull ImmutableContextSet |
fromMap(@NonNull Map<String,String> map)
Creates an
ImmutableContextSet from an existing Map. |
static @NonNull ImmutableContextSet |
fromMultimap(@NonNull Multimap<String,String> multimap)
Creates an
ImmutableContextSet from an existing Multimap. |
static @NonNull ImmutableContextSet |
fromSet(@NonNull ContextSet contextSet)
Creates an new
ImmutableContextSet from an existing Set. |
@NonNull Set<String> |
getValues(@NonNull String key)
Returns a
Set of the values mapped to the given key. |
boolean |
has(@NonNull String key,
@NonNull 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. |
@NonNull Iterator<Map.Entry<String,String>> |
iterator()
Returns an
Iterator over each of the context pairs in this set. |
@NonNull ImmutableContextSet |
makeImmutable()
Deprecated.
|
@NonNull MutableContextSet |
mutableCopy()
Creates a mutable copy of this
ContextSet. |
static @NonNull ImmutableContextSet |
of(@NonNull String key1,
@NonNull String value1,
@NonNull String key2,
@NonNull String value2)
Creates an
ImmutableContextSet from two context pairs. |
static @NonNull ImmutableContextSet |
singleton(@NonNull String key,
@NonNull String value)
Creates an
ImmutableContextSet from a context pair. |
int |
size()
Gets the number of context pairs in the
ContextSet. |
Spliterator<Map.Entry<String,String>> |
spliterator() |
@NonNull Map<String,String> |
toMap()
Deprecated.
|
@NonNull Multimap<String,String> |
toMultimap()
Returns a
Multimap representing the current state of this
ContextSet. |
@NonNull Set<Map.Entry<String,String>> |
toSet()
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcontainsKey, getAnyValue, getValues, has, has, isEmpty, isSatisfiedBy, sizepublic static @NonNull ImmutableContextSet.Builder builder()
ImmutableContextSet.Builder.public static @NonNull ImmutableContextSet singleton(@NonNull String key, @NonNull String value)
ImmutableContextSet from a context pair.singleton in interface ContextSetkey - the keyvalue - the valueNullPointerException - if key or value is nullpublic static @NonNull ImmutableContextSet of(@NonNull String key1, @NonNull String value1, @NonNull String key2, @NonNull String value2)
ImmutableContextSet 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 nullpublic static @NonNull ImmutableContextSet fromEntries(@NonNull Iterable<? extends Map.Entry<String,String>> iterable)
fromEntries in interface ContextSetiterable - the iterable to copy fromNullPointerException - if the iterable is nullpublic static @NonNull ImmutableContextSet fromMap(@NonNull Map<String,String> map)
ImmutableContextSet from an existing Map.fromMap in interface ContextSetmap - the map to copy fromNullPointerException - if the map is nullpublic static @NonNull ImmutableContextSet fromMultimap(@NonNull Multimap<String,String> multimap)
ImmutableContextSet from an existing Multimap.fromMultimap in interface ContextSetmultimap - the multimap to copy fromNullPointerException - if the multimap is nullpublic static @NonNull ImmutableContextSet fromSet(@NonNull ContextSet contextSet)
ImmutableContextSet 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 nullpublic static @NonNull ImmutableContextSet empty()
ImmutableContextSet.empty in interface ContextSetprotected 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@Deprecated public @NonNull 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 ContextSetpublic @NonNull MutableContextSet mutableCopy()
ContextSetContextSet.
A new copy is returned regardless of the
mutability of this set.
mutableCopy in interface ContextSetpublic @NonNull 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@Deprecated public @NonNull 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 ContextSetpublic @NonNull 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 ContextSetpublic @NonNull 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 int hashCode()
public boolean containsKey(@NonNull String key)
ContextSetContextSet contains at least one value for the
given key.containsKey in interface ContextSetkey - the key to check forpublic @NonNull 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 ContextSet