Package org.apache.sis.io.wkt
Class SingletonElement
A mutable set containing either
null or a single element.
If more than one element is added, only the first one is kept.
This is for use with StoredTree.toElements(AbstractParser, Collection, int)
in the common case where we expect exactly one element.- Since:
- 1.1
- Version:
- 1.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the given value if this set is empty.booleanisEmpty()Returnstrueif no value has been specified yet.iterator()Returns an iterator over the elements in this set.intsize()Returns the number of elements in this set, which cannot be greater than 1.Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, remove, retainAll, toArray, toArray, 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, contains, containsAll, remove, retainAll, spliterator, toArray, toArray
-
Field Details
-
value
Element valueThe singleton element, ornullif none.
-
-
Constructor Details
-
SingletonElement
SingletonElement()Creates an initially empty singleton.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Returnstrueif no value has been specified yet.- Specified by:
isEmptyin interfaceCollection<Element>- Specified by:
isEmptyin interfaceSet<Element>- Overrides:
isEmptyin classAbstractCollection<Element>
-
size
public int size()Returns the number of elements in this set, which cannot be greater than 1.- Specified by:
sizein interfaceCollection<Element>- Specified by:
sizein interfaceSet<Element>- Specified by:
sizein classAbstractCollection<Element>
-
iterator
Returns an iterator over the elements in this set. -
add
Adds the given value if this set is empty.- Specified by:
addin interfaceCollection<Element>- Specified by:
addin interfaceSet<Element>- Overrides:
addin classAbstractCollection<Element>
-