@Beta @GwtCompatible public final class MapConstraints extends java.lang.Object
MapConstraint
interface.Constraints
Modifier and Type | Class and Description |
---|---|
(package private) static class |
MapConstraints.ConstrainedAsMapEntries<K,V> |
private static class |
MapConstraints.ConstrainedAsMapValues<K,V> |
private static class |
MapConstraints.ConstrainedBiMap<K,V> |
private static class |
MapConstraints.ConstrainedEntries<K,V> |
(package private) static class |
MapConstraints.ConstrainedEntrySet<K,V> |
private static class |
MapConstraints.ConstrainedListMultimap<K,V> |
(package private) static class |
MapConstraints.ConstrainedMap<K,V> |
private static class |
MapConstraints.ConstrainedMultimap<K,V> |
private static class |
MapConstraints.ConstrainedSetMultimap<K,V> |
private static class |
MapConstraints.ConstrainedSortedSetMultimap<K,V> |
private static class |
MapConstraints.InverseConstraint<K,V> |
private static class |
MapConstraints.NotNullMapConstraint |
Modifier | Constructor and Description |
---|---|
private |
MapConstraints() |
Modifier and Type | Method and Description |
---|---|
private static <K,V> java.util.Map<K,V> |
checkMap(java.util.Map<? extends K,? extends V> map,
MapConstraint<? super K,? super V> constraint) |
private static <K,V> java.util.Collection<V> |
checkValues(K key,
java.lang.Iterable<? extends V> values,
MapConstraint<? super K,? super V> constraint) |
private static <K,V> java.util.Set<java.util.Map.Entry<K,java.util.Collection<V>>> |
constrainedAsMapEntries(java.util.Set<java.util.Map.Entry<K,java.util.Collection<V>>> entries,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified set of
asMap entries,
using the specified constraint. |
private static <K,V> java.util.Map.Entry<K,java.util.Collection<V>> |
constrainedAsMapEntry(java.util.Map.Entry<K,java.util.Collection<V>> entry,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified
asMap entry, using the
specified constraint. |
static <K,V> BiMap<K,V> |
constrainedBiMap(BiMap<K,V> map,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified bimap, using the specified
constraint.
|
private static <K,V> java.util.Collection<java.util.Map.Entry<K,V>> |
constrainedEntries(java.util.Collection<java.util.Map.Entry<K,V>> entries,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified collection (or set) of entries,
using the specified constraint.
|
private static <K,V> java.util.Map.Entry<K,V> |
constrainedEntry(java.util.Map.Entry<K,V> entry,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified entry, using the specified
constraint.
|
private static <K,V> java.util.Set<java.util.Map.Entry<K,V>> |
constrainedEntrySet(java.util.Set<java.util.Map.Entry<K,V>> entries,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified set of entries, using the
specified constraint.
|
static <K,V> ListMultimap<K,V> |
constrainedListMultimap(ListMultimap<K,V> multimap,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified list multimap, using the
specified constraint.
|
static <K,V> java.util.Map<K,V> |
constrainedMap(java.util.Map<K,V> map,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified map, using the specified
constraint.
|
static <K,V> Multimap<K,V> |
constrainedMultimap(Multimap<K,V> multimap,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified multimap, using the specified
constraint.
|
static <K,V> SetMultimap<K,V> |
constrainedSetMultimap(SetMultimap<K,V> multimap,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified set multimap, using the
specified constraint.
|
static <K,V> SortedSetMultimap<K,V> |
constrainedSortedSetMultimap(SortedSetMultimap<K,V> multimap,
MapConstraint<? super K,? super V> constraint)
Returns a constrained view of the specified sorted-set multimap, using the
specified constraint.
|
static MapConstraint<java.lang.Object,java.lang.Object> |
notNull()
Returns a constraint that verifies that neither the key nor the value is
null.
|
public static MapConstraint<java.lang.Object,java.lang.Object> notNull()
NullPointerException
is thrown.public static <K,V> java.util.Map<K,V> constrainedMap(java.util.Map<K,V> map, MapConstraint<? super K,? super V> constraint)
The returned map is not serializable.
map
- the map to constrainconstraint
- the constraint that validates added entriespublic static <K,V> Multimap<K,V> constrainedMultimap(Multimap<K,V> multimap, MapConstraint<? super K,? super V> constraint)
Note that the generated multimap's Multimap.removeAll(java.lang.Object)
and
Multimap.replaceValues(K, java.lang.Iterable<? extends V>)
methods return collections that are not
constrained.
The returned multimap is not serializable.
multimap
- the multimap to constrainconstraint
- the constraint that validates added entriespublic static <K,V> ListMultimap<K,V> constrainedListMultimap(ListMultimap<K,V> multimap, MapConstraint<? super K,? super V> constraint)
Note that the generated multimap's Multimap.removeAll(java.lang.Object)
and
Multimap.replaceValues(K, java.lang.Iterable<? extends V>)
methods return collections that are not
constrained.
The returned multimap is not serializable.
multimap
- the multimap to constrainconstraint
- the constraint that validates added entriespublic static <K,V> SetMultimap<K,V> constrainedSetMultimap(SetMultimap<K,V> multimap, MapConstraint<? super K,? super V> constraint)
Note that the generated multimap's Multimap.removeAll(java.lang.Object)
and
Multimap.replaceValues(K, java.lang.Iterable<? extends V>)
methods return collections that are not
constrained.
The returned multimap is not serializable.
multimap
- the multimap to constrainconstraint
- the constraint that validates added entriespublic static <K,V> SortedSetMultimap<K,V> constrainedSortedSetMultimap(SortedSetMultimap<K,V> multimap, MapConstraint<? super K,? super V> constraint)
Note that the generated multimap's Multimap.removeAll(java.lang.Object)
and
Multimap.replaceValues(K, java.lang.Iterable<? extends V>)
methods return collections that are not
constrained.
The returned multimap is not serializable.
multimap
- the multimap to constrainconstraint
- the constraint that validates added entriesprivate static <K,V> java.util.Map.Entry<K,V> constrainedEntry(java.util.Map.Entry<K,V> entry, MapConstraint<? super K,? super V> constraint)
Map.Entry.setValue(V)
operation will be verified with the
constraint.entry
- the entry to constrainconstraint
- the constraint for the entryprivate static <K,V> java.util.Map.Entry<K,java.util.Collection<V>> constrainedAsMapEntry(java.util.Map.Entry<K,java.util.Collection<V>> entry, MapConstraint<? super K,? super V> constraint)
asMap
entry, using the
specified constraint. The Map.Entry.setValue(V)
operation will be verified
with the constraint, and the collection returned by Map.Entry.getValue()
will be similarly constrained.entry
- the asMap
entry to constrainconstraint
- the constraint for the entryprivate static <K,V> java.util.Set<java.util.Map.Entry<K,java.util.Collection<V>>> constrainedAsMapEntries(java.util.Set<java.util.Map.Entry<K,java.util.Collection<V>>> entries, MapConstraint<? super K,? super V> constraint)
asMap
entries,
using the specified constraint. The Map.Entry.setValue(V)
operation will
be verified with the constraint, and the collection returned by Map.Entry.getValue()
will be similarly constrained. The add
and addAll
operations simply forward to the underlying set, which throws an
UnsupportedOperationException
per the multimap specification.entries
- the entries to constrainconstraint
- the constraint for the entriesprivate static <K,V> java.util.Collection<java.util.Map.Entry<K,V>> constrainedEntries(java.util.Collection<java.util.Map.Entry<K,V>> entries, MapConstraint<? super K,? super V> constraint)
Map.Entry.setValue(V)
operation will
be verified with the constraint, along with add operations on the returned
collection. The add
and addAll
operations simply forward to
the underlying collection, which throws an UnsupportedOperationException
per the map and multimap specification.entries
- the entries to constrainconstraint
- the constraint for the entriesprivate static <K,V> java.util.Set<java.util.Map.Entry<K,V>> constrainedEntrySet(java.util.Set<java.util.Map.Entry<K,V>> entries, MapConstraint<? super K,? super V> constraint)
Map.Entry.setValue(V)
operation will be verified
with the constraint, along with add operations on the returned set. The
add
and addAll
operations simply forward to the underlying
set, which throws an UnsupportedOperationException
per the map and
multimap specification.
The returned multimap is not serializable.
entries
- the entries to constrainconstraint
- the constraint for the entriespublic static <K,V> BiMap<K,V> constrainedBiMap(BiMap<K,V> map, MapConstraint<? super K,? super V> constraint)
The returned bimap is not serializable.
map
- the bimap to constrainconstraint
- the constraint that validates added entriesprivate static <K,V> java.util.Collection<V> checkValues(K key, java.lang.Iterable<? extends V> values, MapConstraint<? super K,? super V> constraint)
private static <K,V> java.util.Map<K,V> checkMap(java.util.Map<? extends K,? extends V> map, MapConstraint<? super K,? super V> constraint)