@Immutable 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 ImmutableContextSet.Builder |
builder()
Creates an
ImmutableContextSet.Builder. |
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 ImmutableContextSet |
empty()
Returns an empty
ImmutableContextSet. |
boolean |
equals(Object o) |
static ImmutableContextSet |
fromEntries(Iterable<? extends Map.Entry<String,String>> iterable)
|
static ImmutableContextSet |
fromMap(Map<String,String> map)
Creates an
ImmutableContextSet from an existing Map. |
static ImmutableContextSet |
fromMultimap(Multimap<String,String> multimap)
Creates an
ImmutableContextSet from an existing Multimap. |
static ImmutableContextSet |
fromSet(ContextSet contextSet)
Creates an new
ImmutableContextSet 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()
Deprecated.
|
MutableContextSet |
mutableCopy()
Creates a mutable copy of this
ContextSet. |
static ImmutableContextSet |
of(String key1,
String value1,
String key2,
String value2)
Creates an
ImmutableContextSet from two context pairs. |
static ImmutableContextSet |
singleton(String key,
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() |
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, getAnyValue, getValues, has, has, isEmpty, isSatisfiedBy, size@Nonnull public static ImmutableContextSet.Builder builder()
ImmutableContextSet.Builder.@Nonnull public static 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 null@Nonnull public static 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 null@Nonnull public static ImmutableContextSet 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 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 null@Nonnull public static 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 null@Nonnull public static 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 null@Nonnull public static 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@Nonnull @Deprecated 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 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 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.