B - The type of elements in the backing set.E - The type of elements in this set.public abstract class DerivedSet<B,E> extends AbstractSet<E> implements CheckedCollection<E>, Serializable
baseToDerived(B) and derivedToBase(E) methods. This set do not supports null
value, since null is used when no mapping from base to this exists.
This class is serializable if the underlying base set is serializable too.
This class is not thread-safe. Synchronizations (if wanted) are user's reponsability.
| Modifier and Type | Field and Description |
|---|---|
protected Set<B> |
base
The base set whose values are derived from.
|
| Constructor and Description |
|---|
DerivedSet(Set<B> base)
Deprecated.
Use
DerivedSet(Set,Class) instead. |
DerivedSet(Set<B> base,
Class<E> derivedType)
Creates a new derived set from the specified base set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E element)
Ensures that this set contains the specified element.
|
protected abstract E |
baseToDerived(B element)
Transforms a value in the base set to a value in this set.
|
boolean |
contains(Object element)
Returns
true if this set contains the specified element. |
protected abstract B |
derivedToBase(E element)
Transforms a value in this set to a value in the base set.
|
Class<E> |
getElementType()
Returns the derived element type.
|
boolean |
isEmpty()
Returns
true if this set contains no elements. |
Iterator<E> |
iterator()
Returns an iterator over the elements contained in this set.
|
boolean |
remove(Object element)
Removes a single instance of the specified element from this set.
|
int |
size()
Returns the number of elements in this set.
|
equals, hashCode, removeAlladdAll, clear, containsAll, retainAll, toArray, toArray, toStringaddAll, clear, containsAll, equals, hashCode, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArrayaddAll, clear, containsAll, retainAll, spliterator, toArray, toArrayprotected final Set<B> base
baseToDerived(B),
derivedToBase(E)public DerivedSet(Set<B> base)
DerivedSet(Set,Class) instead.base - The base set.public Class<E> getElementType()
getElementType in interface CheckedCollection<E>protected abstract E baseToDerived(B element)
null.element - A value in the base set.element, or null.protected abstract B derivedToBase(E element)
element - A value in this set.public Iterator<E> iterator()
baseToDerived(B) for each element.public int size()
iterator.size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean isEmpty()
true if this set contains no elements.isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>true if this set contains no elements.public boolean contains(Object element)
true if this set contains the specified element. The default implementation
invokes base.contains(derivedToBase(element))
.contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>element - object to be checked for containment in this set.true if this set contains the specified element.public boolean add(E element) throws UnsupportedOperationException
base.add(derivedToBase(element)).add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>element - element whose presence in this set is to be ensured.true if the set changed as a result of the call.UnsupportedOperationException - if the base set doesn't supports the
add operation.public boolean remove(Object element) throws UnsupportedOperationException
base.remove(derivedToBase(element))
.remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>element - element to be removed from this set, if present.true if the set contained the specified element.UnsupportedOperationException - if the base set doesn't supports the
remove operation.Copyright © 1996–2019 Geotools. All rights reserved.