Package eu.bandm.tools.util.multi
Class UnmodifiableMultimap<A,B>
- Type Parameters:
A
- type of the domain elementsB
- type of the range elements
- All Implemented Interfaces:
Multimap<A,
,B> Iterable<Map.Entry<A,
,B>> Collection<Map.Entry<A,
,B>> BiPredicate<A,
,B> Set<Map.Entry<A,
B>>
abstract class UnmodifiableMultimap<A,B>
extends AbstractCollection<Map.Entry<A,B>>
implements Multimap<A,B>
A wrapper to protect the contents of an instance of a multimap.
Not to be called by the user, but by the factory methods in
Multimaps
.
To create such a wrapper, use Multimaps.unmodifiableMultimap(eu.bandm.tools.util.multi.Multimap<? extends A, ? extends B>)
.
All methods which try to change the state of this instance
throw an UnsupportedOperationException.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a pair to this multimap.final boolean
Whether this multimap contains a pair with the given components.Returns the set of right components of pairs with a given left component in this multimap.imageMap()
Returns a map which maps each A which appears as a left component to a set of all B which appear as its right component.Returns the set of left components of pairs with a given right component in this multimap.Returns a map which maps each B which appears as a right component to a set of all A which appear as its left component.final boolean
Removes a pair from this multimap.final boolean
removeAllDomain
(Collection<? extends A> a) Removes all pairs with a left component in the given collection from this multimap.final boolean
Convenience method for untyped remove.final boolean
removeAllRange
(Collection<? extends B> b) Removes all pairs with a right component in the given collection from this multimap.final boolean
Convenience method for untyped remove.final boolean
removeDomain
(A a) Removes all pairs with a given left component from this multimap.final boolean
Convenience method for untyped remove.final boolean
removeRange
(B b) Removes all pairs with a given right component from this multimap.final boolean
Convenience method for untyped remove.final boolean
removeUnchecked
(Object a, Object b) Convenience method for untyped remove.final boolean
retainAllDomain
(Collection<? extends A> a) Removes from this multimap all pairs with a left component which is not in the given collection.final boolean
Convenience method for untyped remove.final boolean
retainAllRange
(Collection<? extends B> b) Removes from this multimap all pairs with a right component which is not in the given collection.final boolean
Convenience method for untyped remove.Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.function.BiPredicate
and, negate, or
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface eu.bandm.tools.util.multi.Multimap
addAll, containsAll, containsUnchecked, domain, imageAll, imageAllUnchecked, imageUnchecked, preimageAll, preimageAllUnchecked, preimageUnchecked, range, removeAll, retainAll, test, toArray, toArray
-
Constructor Details
-
UnmodifiableMultimap
public UnmodifiableMultimap()Only constructor
-
-
Method Details
-
add
Adds a pair to this multimap. This operation must be stable: adding a pair thatequals
any pair contained in this multimap componentwise must not change this multimap.- Specified by:
add
in interfaceMultimap<A,
B> - Parameters:
a
- the left component of the pair to addb
- the right component of the pair to add- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always
-
contains
Description copied from interface:Multimap
Whether this multimap contains a pair with the given components. -
remove
Removes a pair from this multimap. Removing a pair thatequals
no pair contained in this multimap componentwise must not change this multimap.- Specified by:
remove
in interfaceMultimap<A,
B> - Parameters:
a
- the left component of the pair to remove.b
- the right component of the pair to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always
-
removeUnchecked
Convenience method for untyped remove.- Specified by:
removeUnchecked
in interfaceMultimap<A,
B> - Parameters:
a
- the left component of the pair to remove.b
- the right component of the pair to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always- See Also:
-
removeDomain
Removes all pairs with a given left component from this multimap. The effect of the implementation on this multimap must be equivalent to the following code:removeDomain(final A a) { for (B b : new HashSet<B>(range())) remove(a, b) ; }
- Specified by:
removeDomain
in interfaceMultimap<A,
B> - Parameters:
a
- the left component of all pairs to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always
-
removeDomainUnchecked
Convenience method for untyped remove.- Specified by:
removeDomainUnchecked
in interfaceMultimap<A,
B> - Parameters:
a
- the left component of all pairs to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always- See Also:
-
removeRange
Removes all pairs with a given right component from this multimap. The effect of the implementation on this multimap must be equivalent to the following code:removeRange(final B b) { for (A a : new HashSet<A>(domain())) remove(a, b) ; }
- Specified by:
removeRange
in interfaceMultimap<A,
B> - Parameters:
b
- the right component of all pairs to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always
-
removeRangeUnchecked
Convenience method for untyped remove. Removes all pairs with a given right component from this multimap.- Specified by:
removeRangeUnchecked
in interfaceMultimap<A,
B> - Parameters:
b
- the right component of all pairs to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always- See Also:
-
removeAllDomain
Removes all pairs with a left component in the given collection from this multimap.- Specified by:
removeAllDomain
in interfaceMultimap<A,
B> - Parameters:
a
- the set of left component of all pairs to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always
-
removeAllDomainUnchecked
Convenience method for untyped remove.- Specified by:
removeAllDomainUnchecked
in interfaceMultimap<A,
B> - Parameters:
a
- the set of left component of all pairs to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always- See Also:
-
retainAllDomain
Removes from this multimap all pairs with a left component which is not in the given collection.- Specified by:
retainAllDomain
in interfaceMultimap<A,
B> - Parameters:
a
- the set of left component of all pairs not to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always
-
retainAllDomainUnchecked
Convenience method for untyped remove.- Specified by:
retainAllDomainUnchecked
in interfaceMultimap<A,
B> - Parameters:
a
- the set of left component of all pairs not to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always- See Also:
-
removeAllRange
Removes all pairs with a right component in the given collection from this multimap.- Specified by:
removeAllRange
in interfaceMultimap<A,
B> - Parameters:
b
- the set of the right component of all pairs to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always
-
removeAllRangeUnchecked
Convenience method for untyped remove. Removes all pairs with a right component in the given collection from this multimap.- Specified by:
removeAllRangeUnchecked
in interfaceMultimap<A,
B> - Parameters:
b
- the set of the right component of all pairs to remove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always- See Also:
-
retainAllRange
Removes from this multimap all pairs with a right component which is not in the given collection.- Specified by:
retainAllRange
in interfaceMultimap<A,
B> - Parameters:
b
- the set of the right component of all pairs not emove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always
-
retainAllRangeUnchecked
Convenience method for untyped remove. Removes all pairs with a right component which is not the given collection from this multimap.- Specified by:
retainAllRangeUnchecked
in interfaceMultimap<A,
B> - Parameters:
b
- the set of the right component of all pairs not emove.- Returns:
- whether this multimap has been changed by this operation
- Throws:
UnsupportedOperationException
- always- See Also:
-
image
Description copied from interface:Multimap
Returns the set of right components of pairs with a given left component in this multimap.The returned set need not be modifiable. The behaviour of this multimap after successfully modifying the returned set is unspecified.
-
imageMap
Description copied from interface:Multimap
Returns a map which maps each A which appears as a left component to a set of all B which appear as its right component. The result is backed by the argument. Subsequent changes to either Collection are reflected by the other. -
preimage
Description copied from interface:Multimap
Returns the set of left components of pairs with a given right component in this multimap.The returned set need not be modifiable. The behaviour of this multimap after successfully modifying the returned set is unspecified.
-
preimageMap
Description copied from interface:Multimap
Returns a map which maps each B which appears as a right component to a set of all A which appear as its left component. The result is backed by the argument. Subsequent changes to either Collection are reflected by the other.- Specified by:
preimageMap
in interfaceMultimap<A,
B> - Returns:
- a map which maps each B which appears as a right component to a set of all A which appear as its left component.
-