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 |
constrainedBiMap(BiMap
Deprecated.
Returns a constrained view of the specified bimap, using the specified constraint.
|
static <K |
constrainedListMultimap(ListMultimap
Deprecated.
Returns a constrained view of the specified list multimap, using the specified constraint.
|
static <K |
constrainedMap(Map
Deprecated.
Returns a constrained view of the specified map, using the specified constraint.
|
static <K |
constrainedMultimap(Multimap
Deprecated.
Returns a constrained view of the specified multimap, using the specified constraint.
|
static <K |
constrainedSetMultimap(SetMultimap
Deprecated.
Returns a constrained view of the specified set multimap, using the specified constraint.
|
static <K |
constrainedSortedSetMultimap(SortedSetMultimap
Deprecated.
Returns a constrained view of the specified sorted-set multimap, using the specified constraint.
|
static MapConstraint |
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 constrain
constraint
- the constraint that validates added entries
public static <K,V> Multimap <K ,V> constrainedMultimap(Multimap <K ,V> multimap, MapConstraint <? super K ,? super V> constraint)
Note that the generated multimap's Multimap
and Multimap
methods return collections that are not constrained.
The returned multimap is not serializable.
multimap
- the multimap to constrain
constraint
- the constraint that validates added entries
public static <K,V> ListMultimap <K ,V> constrainedListMultimap(ListMultimap <K ,V> multimap, MapConstraint <? super K ,? super V> constraint)
Note that the generated multimap's Multimap
and Multimap
methods return collections that are not constrained.
The returned multimap is not serializable.
multimap
- the multimap to constrain
constraint
- the constraint that validates added entries
public static <K,V> SetMultimap <K ,V> constrainedSetMultimap(SetMultimap <K ,V> multimap, MapConstraint <? super K ,? super V> constraint)
Note that the generated multimap's Multimap
and Multimap
methods return collections that are not constrained.
The returned multimap is not serializable.
multimap
- the multimap to constrain
constraint
- the constraint that validates added entries
public static <K,V> SortedSetMultimap <K ,V> constrainedSortedSetMultimap(SortedSetMultimap <K ,V> multimap, MapConstraint <? super K ,? super V> constraint)
Note that the generated multimap's Multimap
and Multimap
methods return collections that are not constrained.
The returned multimap is not serializable.
multimap
- the multimap to constrain
constraint
- the constraint that validates added entries
public 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 constrain
constraint
- the constraint that validates added entries