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.-
Field Summary
Fields inherited from interface eu.bandm.tools.util.multi.Multimap
DEFAULT_PAIR_FORMAT_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a pair to this multimap.final booleanWhether 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 booleanRemoves a pair from this multimap.final booleanremoveAllDomain(Collection<? extends A> a) Removes all pairs with a left component in the given collection from this multimap.final booleanConvenience method for untyped remove.final booleanremoveAllRange(Collection<? extends B> b) Removes all pairs with a right component in the given collection from this multimap.final booleanConvenience method for untyped remove.final booleanremoveDomain(A a) Removes all pairs with a given left component from this multimap.final booleanConvenience method for untyped remove.final booleanremoveRange(B b) Removes all pairs with a given right component from this multimap.final booleanConvenience method for untyped remove.final booleanremoveUnchecked(Object a, Object b) Convenience method for untyped remove.final booleanretainAllDomain(Collection<? extends A> a) Removes from this multimap all pairs with a left component which is not in the given collection.final booleanConvenience method for untyped remove.final booleanretainAllRange(Collection<? extends B> b) Removes from this multimap all pairs with a right component which is not in the given collection.final booleanConvenience method for untyped remove.Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.function.BiPredicate
and, negate, orMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods 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, toString, toString
-
Constructor Details
-
UnmodifiableMultimap
public UnmodifiableMultimap()Only constructor
-
-
Method Details
-
add
Adds a pair to this multimap. This operation must be stable: adding a pair thatequalsany pair contained in this multimap componentwise must not change this multimap.- Specified by:
addin 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:MultimapWhether this multimap contains a pair with the given components. -
remove
Removes a pair from this multimap. Removing a pair thatequalsno pair contained in this multimap componentwise must not change this multimap.- Specified by:
removein 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:
removeUncheckedin 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:
removeDomainin 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:
removeDomainUncheckedin 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:
removeRangein 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:
removeRangeUncheckedin 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:
removeAllDomainin 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:
removeAllDomainUncheckedin 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:
retainAllDomainin 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:
retainAllDomainUncheckedin 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:
removeAllRangein 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:
removeAllRangeUncheckedin 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:
retainAllRangein 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:
retainAllRangeUncheckedin 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:MultimapReturns 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:MultimapReturns 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:MultimapReturns 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:MultimapReturns 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:
preimageMapin 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.
-