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 long
For 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 boolean
Ensures that this set contains the specified element.final boolean
Returnstrue
if this set contains the specified element.final boolean
Removes a single instance of the specified element from this set.Methods inherited from class org.apache.sis.util.collection.DerivedSet
add, create, getElementType, isEmpty, iterator
Methods inherited from class org.apache.sis.internal.util.SetOfUnknownSize
equals, isSizeKnown, removeAll, size, spliterator, toArray, toArray
Methods inherited from class java.util.AbstractSet
hashCode
Methods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, retainAll, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods 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.storage
set like below:- Specified by:
add
in interfaceCollection<S>
- Specified by:
add
in interfaceSet<S>
- Overrides:
add
in classDerivedSet<S,
E> - Parameters:
element
- element whose presence in this set is to be ensured.- Returns:
true
if the set changed as a result of the call.- Throws:
UnsupportedOperationException
- if the DerivedSet.storage set doesn't supports theadd
operation.
-
contains
Returnstrue
if this set contains the specified element. This method first checks if the given element is an instance ofDerivedSet.getElementType()
, then delegates to theDerivedSet.storage
set like below:- Specified by:
contains
in interfaceCollection<S>
- Specified by:
contains
in interfaceSet<S>
- Overrides:
contains
in classAbstractCollection<E>
- Parameters:
element
- object to be checked for containment in this set.- Returns:
true
if 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.storage
set like below:- Specified by:
remove
in interfaceCollection<S>
- Specified by:
remove
in interfaceSet<S>
- Overrides:
remove
in classAbstractCollection<E>
- Parameters:
element
- element to be removed from this set, if present.- Returns:
true
if the set contained the specified element.- Throws:
UnsupportedOperationException
- if the DerivedSet.storage set doesn't supports theremove
operation.
-