Preconditions
for basic checks. In place of
constrained maps, we encourage you to check your preconditions
explicitly instead of leaving that work to the map implementation.
For the specific case of rejecting null, consider ImmutableMap
.
This class is scheduled for removal in Guava 20.0.@Beta @GwtCompatible @Deprecated public final class MapConstraints extends Object
MapConstraint
interface.Constraints
Modifier and Type | Method and Description |
---|---|
static <K,V> BiMap<K,V> |
constrainedBiMap(BiMap<K,V> map,
MapConstraint<? super K,? super V> constraint)
Deprecated.
Returns a constrained view of the specified bimap, using the specified
constraint.
|
static <K,V> ListMultimap<K,V> |
constrainedListMultimap(ListMultimap<K,V> multimap,
MapConstraint<? super K,? super V> constraint)
Deprecated.
Returns a constrained view of the specified list multimap, using the
specified constraint.
|
static <K,V> Map<K,V> |
constrainedMap(Map<K,V> map,
MapConstraint<? super K,? super V> constraint)
Deprecated.
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)
Deprecated.
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)
Deprecated.
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)
Deprecated.
Returns a constrained view of the specified sorted-set multimap, using the
specified constraint.
|
static MapConstraint<Object,Object> |
notNull()
Deprecated.
Returns a constraint that verifies that neither the key nor the value is
null.
|
public static MapConstraint<Object,Object> notNull()
NullPointerException
is thrown.public static <K,V> Map<K,V> constrainedMap(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 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 entriesCopyright © 2010-2015. All Rights Reserved.