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 TypeMethodDescriptionboolean
Adds the given value if this set is empty.boolean
isEmpty()
Returnstrue
if no value has been specified yet.iterator()
Returns an iterator over the elements in this set.int
size()
Returns the number of elements in this set, which cannot be greater than 1.Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, remove, retainAll, toArray, toArray, 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, contains, containsAll, remove, retainAll, spliterator, toArray, toArray
-
Field Details
-
value
Element valueThe singleton element, ornull
if none.
-
-
Constructor Details
-
SingletonElement
SingletonElement()Creates an initially empty singleton.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Returnstrue
if no value has been specified yet.- Specified by:
isEmpty
in interfaceCollection<Element>
- Specified by:
isEmpty
in interfaceSet<Element>
- Overrides:
isEmpty
in classAbstractCollection<Element>
-
size
public int size()Returns the number of elements in this set, which cannot be greater than 1.- Specified by:
size
in interfaceCollection<Element>
- Specified by:
size
in interfaceSet<Element>
- Specified by:
size
in classAbstractCollection<Element>
-
iterator
Returns an iterator over the elements in this set. -
add
Adds the given value if this set is empty.- Specified by:
add
in interfaceCollection<Element>
- Specified by:
add
in interfaceSet<Element>
- Overrides:
add
in classAbstractCollection<Element>
-