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 21.0.@Beta @GwtCompatible @Deprecated public final class MapConstraints extends Object
MapConstraint
interface.Constraints
Modifier and Type | Method and Description |
---|---|
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.
|
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> 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 entriesCopyright © 2010-2016. All Rights Reserved.