Package com.google.common.collect
Class MapConstraints
- java.lang.Object
-
- com.google.common.collect.MapConstraints
-
@Beta @GwtCompatible @Deprecated public final class MapConstraints extends java.lang.Object
Deprecated.UsePreconditions
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, considerImmutableMap
. This class is scheduled for removal in Guava 21.0.Factory and utilities pertaining to theMapConstraint
interface.- Since:
- 3.0
- See Also:
Constraints
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
MapConstraints.ConstrainedAsMapEntries<K,V>
Deprecated.private static class
MapConstraints.ConstrainedAsMapValues<K,V>
Deprecated.private static class
MapConstraints.ConstrainedEntries<K,V>
Deprecated.(package private) static class
MapConstraints.ConstrainedEntrySet<K,V>
Deprecated.private static class
MapConstraints.ConstrainedListMultimap<K,V>
Deprecated.(package private) static class
MapConstraints.ConstrainedMap<K,V>
Deprecated.private static class
MapConstraints.ConstrainedMultimap<K,V>
Deprecated.
-
Constructor Summary
Constructors Modifier Constructor Description private
MapConstraints()
Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method 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)
Deprecated.private static <K,V>
java.util.Collection<V>checkValues(K key, java.lang.Iterable<? extends V> values, MapConstraint<? super K,? super V> constraint)
Deprecated.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)
Deprecated.Returns a constrained view of the specified set ofasMap
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)
Deprecated.Returns a constrained view of the specifiedasMap
entry, 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)
Deprecated.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)
Deprecated.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)
Deprecated.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)
Deprecated.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)
Deprecated.Returns a constrained view of the specified map, using the specified constraint.
-
-
-
Method Detail
-
constrainedMap
public static <K,V> java.util.Map<K,V> constrainedMap(java.util.Map<K,V> map, MapConstraint<? super K,? super V> constraint)
Deprecated.Returns a constrained view of the specified map, using the specified constraint. Any operations that add new mappings will call the provided constraint. However, this method does not verify that existing mappings satisfy the constraint.The returned map is not serializable.
- Parameters:
map
- the map to constrainconstraint
- the constraint that validates added entries- Returns:
- a constrained view of the specified map
-
constrainedListMultimap
public 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. Any operations that add new mappings will call the provided constraint. However, this method does not verify that existing mappings satisfy the constraint.Note that the generated multimap's
Multimap.removeAll(java.lang.Object)
andMultimap.replaceValues(K, java.lang.Iterable<? extends V>)
methods return collections that are not constrained.The returned multimap is not serializable.
- Parameters:
multimap
- the multimap to constrainconstraint
- the constraint that validates added entries- Returns:
- a constrained view of the specified multimap
-
constrainedEntry
private static <K,V> java.util.Map.Entry<K,V> constrainedEntry(java.util.Map.Entry<K,V> entry, MapConstraint<? super K,? super V> constraint)
Deprecated.Returns a constrained view of the specified entry, using the specified constraint. TheMap.Entry.setValue(V)
operation will be verified with the constraint.- Parameters:
entry
- the entry to constrainconstraint
- the constraint for the entry- Returns:
- a constrained view of the specified entry
-
constrainedAsMapEntry
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)
Deprecated.Returns a constrained view of the specifiedasMap
entry, using the specified constraint. TheMap.Entry.setValue(V)
operation will be verified with the constraint, and the collection returned byMap.Entry.getValue()
will be similarly constrained.- Parameters:
entry
- theasMap
entry to constrainconstraint
- the constraint for the entry- Returns:
- a constrained view of the specified entry
-
constrainedAsMapEntries
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)
Deprecated.Returns a constrained view of the specified set ofasMap
entries, using the specified constraint. TheMap.Entry.setValue(V)
operation will be verified with the constraint, and the collection returned byMap.Entry.getValue()
will be similarly constrained. Theadd
andaddAll
operations simply forward to the underlying set, which throws anUnsupportedOperationException
per the multimap specification.- Parameters:
entries
- the entries to constrainconstraint
- the constraint for the entries- Returns:
- a constrained view of the entries
-
constrainedEntries
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)
Deprecated.Returns a constrained view of the specified collection (or set) of entries, using the specified constraint. TheMap.Entry.setValue(V)
operation will be verified with the constraint, along with add operations on the returned collection. Theadd
andaddAll
operations simply forward to the underlying collection, which throws anUnsupportedOperationException
per the map and multimap specification.- Parameters:
entries
- the entries to constrainconstraint
- the constraint for the entries- Returns:
- a constrained view of the specified entries
-
constrainedEntrySet
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)
Deprecated.Returns a constrained view of the specified set of entries, using the specified constraint. TheMap.Entry.setValue(V)
operation will be verified with the constraint, along with add operations on the returned set. Theadd
andaddAll
operations simply forward to the underlying set, which throws anUnsupportedOperationException
per the map and multimap specification.The returned multimap is not serializable.
- Parameters:
entries
- the entries to constrainconstraint
- the constraint for the entries- Returns:
- a constrained view of the specified entries
-
checkValues
private static <K,V> java.util.Collection<V> checkValues(K key, java.lang.Iterable<? extends V> values, MapConstraint<? super K,? super V> constraint)
Deprecated.
-
checkMap
private static <K,V> java.util.Map<K,V> checkMap(java.util.Map<? extends K,? extends V> map, MapConstraint<? super K,? super V> constraint)
Deprecated.
-
-