Package org.apache.sis.util.collection
Class DerivedSet.Invertible<S,E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.apache.sis.internal.util.SetOfUnknownSize<E>
org.apache.sis.util.collection.DerivedSet<S,E>
org.apache.sis.util.collection.DerivedSet.Invertible<S,E>
- Type Parameters:
S- the type of elements in the storage set.E- the type of elements in this set.
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Set<E>,CheckedContainer<E>
- Direct Known Subclasses:
DerivedSet.Bijective
- Enclosing class:
- DerivedSet<S,
E>
A
DerivedSet for invertible converters. Availability of the inverse conversion
allows us to delegate the contains(Object) and remove(Object)
operations to the DerivedSet.storage set instead of iterating over all elements.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObjectConverter<E,S> The converter from the derived to the storage type.private static final longFor cross-version compatibility.Fields inherited from class org.apache.sis.util.collection.DerivedSet
converter, storage -
Constructor Summary
ConstructorsConstructorDescriptionInvertible(Set<S> storage, ObjectConverter<S, E> converter) Creates a new derived set from the specified storage set. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanEnsures that this set contains the specified element.final booleanReturnstrueif this set contains the specified element.final booleanRemoves a single instance of the specified element from this set.Methods inherited from class org.apache.sis.util.collection.DerivedSet
add, create, getElementType, isEmpty, iteratorMethods inherited from class org.apache.sis.internal.util.SetOfUnknownSize
equals, isSizeKnown, removeAll, size, spliterator, toArray, toArrayMethods inherited from class java.util.AbstractSet
hashCodeMethods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, retainAll, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, streamMethods inherited from interface java.util.Set
addAll, clear, containsAll, retainAll
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
inverse
The converter from the derived to the storage type.
-
-
Constructor Details
-
Invertible
Invertible(Set<S> storage, ObjectConverter<S, E> converter) Creates a new derived set from the specified storage set.- Parameters:
storage- the set which actually store the elements.converter- the type of elements in this derived set.
-
-
Method Details
-
add
Ensures that this set contains the specified element. This method first checks if the given element is non-null, then delegates to theDerivedSet.storageset like below:- Specified by:
addin interfaceCollection<S>- Specified by:
addin interfaceSet<S>- Overrides:
addin classDerivedSet<S,E> - Parameters:
element- element whose presence in this set is to be ensured.- Returns:
trueif the set changed as a result of the call.- Throws:
UnsupportedOperationException- if the DerivedSet.storage set doesn't supports theaddoperation.
-
contains
Returnstrueif this set contains the specified element. This method first checks if the given element is an instance ofDerivedSet.getElementType(), then delegates to theDerivedSet.storageset like below:- Specified by:
containsin interfaceCollection<S>- Specified by:
containsin interfaceSet<S>- Overrides:
containsin classAbstractCollection<E>- Parameters:
element- object to be checked for containment in this set.- Returns:
trueif this set contains the specified element.
-
remove
Removes a single instance of the specified element from this set. This method first checks if the given element is an instance ofDerivedSet.getElementType(), then delegates to theDerivedSet.storageset like below:- Specified by:
removein interfaceCollection<S>- Specified by:
removein interfaceSet<S>- Overrides:
removein classAbstractCollection<E>- Parameters:
element- element to be removed from this set, if present.- Returns:
trueif the set contained the specified element.- Throws:
UnsupportedOperationException- if the DerivedSet.storage set doesn't supports theremoveoperation.
-