public final class CellSet extends java.util.AbstractSet<Cell<?>> implements CellCollection
Cell
s having no more than one cell having a given name.
The iteration order is not defined for a CellSet
but may be specified
by an API method returning an instance.
Null elements are not permitted in a CellSet
.
CellDefinition.name()
,
Record
Constructor and Description |
---|
CellSet()
Creates an new, mutable empty
CellSet instance. |
CellSet(java.lang.Iterable<Cell<?>> cells)
Creates a new, mutable
CellSet instance containing the Cell s from the specified
Iterable in the order returned by the iterator. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Cell<?> cell)
Adds the specified
Cell to this set if a cell having the same cell name is not already present. |
boolean |
contains(java.lang.Object o)
Returns
true if this set contains the specified Cell or another cell having the same name. |
<T> java.util.Optional<T> |
get(CellDefinition<T> cellDefinition)
Retrieve a cell by
CellDefinition . |
java.util.Optional<?> |
get(java.lang.String name)
Retrieve a cell by name.
|
java.util.Iterator<Cell<?>> |
iterator()
Returns an
Iterator over the cells in this set. |
static CellSet |
of(Cell<?>... cells)
Creates a new, mutable
CellSet instance containing the specified Cell instances. |
<T> java.util.Optional<Cell<T>> |
remove(CellDefinition<T> definition)
Removes the
Cell with this definition from this set if it is present. |
boolean |
remove(java.lang.Object o)
Removes the specified
Cell . |
java.util.Optional<Cell<?>> |
remove(java.lang.String name)
Removes a
Cell with the specified name. |
Cell<?> |
set(Cell<?> cell)
Adds the specified
Cell to this set if a cell having the same name is not already present or
replaces the existing cell if a cell of the same name is already present. |
int |
size() |
java.util.Spliterator<Cell<?>> |
spliterator()
Creates a
Spliterator over the cells in this set. |
addAll, clear, containsAll, isEmpty, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public CellSet()
CellSet
instance.public CellSet(java.lang.Iterable<Cell<?>> cells)
CellSet
instance containing the Cell
s from the specified
Iterable
in the order returned by the iterator. If more than one cell with the
same name is presented from the iterable, only the last like-named cell, as observed by the
iterator, is kept.cells
- the Iterable
over Cell
instances from which a new CellSet
is createdjava.lang.NullPointerException
- if cells
is null
or cells
contains a null
elementpublic static CellSet of(Cell<?>... cells)
CellSet
instance containing the specified Cell
instances.
If more than one cell with the same name is present in the collection, only the last like-named cell
is kept.cells
- the Cell
instances for the new CellSet
CellSet
containing the specified cellsjava.lang.NullPointerException
- if cells
contains a null
public <T> java.util.Optional<T> get(CellDefinition<T> cellDefinition)
CellCollection
CellDefinition
. If this record contains a cell whose definition matches
the supplied definition (in both name and type) then that cell's value is
wrapped in an Optional
and returned. If this record contains no
matching cell then an empty Optional
is returned.get
in interface CellCollection
T
- the cell JDK typecellDefinition
- cell to retrieveOptional
with the cell value or an empty Optional
if the record contains no matching cellpublic java.util.Optional<?> get(java.lang.String name)
CellCollection
Optional
and returned. If this record contains no
matching cell then an empty Optional
is returned.get
in interface CellCollection
name
- cell to retrieveOptional
with the cell value or an empty Optional
if the record contains no matching cellpublic boolean add(Cell<?> cell)
Cell
to this set if a cell having the same cell name is not already present.add
in interface java.util.Collection<Cell<?>>
add
in interface java.util.Set<Cell<?>>
add
in class java.util.AbstractCollection<Cell<?>>
cell
- the new Cell
to add to this setjava.lang.NullPointerException
- if cell
is null
public Cell<?> set(Cell<?> cell)
Cell
to this set if a cell having the same name is not already present or
replaces the existing cell if a cell of the same name is already present.cell
- the new Cell
to put into this setCell
having the same name as cell
, if any; null
if a like-named
cell is not presentjava.lang.NullPointerException
- if cell
is null
public boolean contains(java.lang.Object o)
true
if this set contains the specified Cell
or another cell having the same name.contains
in interface java.util.Collection<Cell<?>>
contains
in interface java.util.Set<Cell<?>>
contains
in class java.util.AbstractCollection<Cell<?>>
o
- true
if this set contains the specified celljava.lang.NullPointerException
- if o
is null
java.lang.ClassCastException
- if o
is not a Cell
public boolean remove(java.lang.Object o)
Cell
.remove
in interface java.util.Collection<Cell<?>>
remove
in interface java.util.Set<Cell<?>>
remove
in class java.util.AbstractCollection<Cell<?>>
o
- true
if this set contained the specified celljava.lang.NullPointerException
- if o
is null
java.lang.ClassCastException
- if o
is not a Cell
public java.util.Optional<Cell<?>> remove(java.lang.String name)
Cell
with the specified name.name
- name of cell to be removedjava.lang.NullPointerException
- if name
is null
public <T> java.util.Optional<Cell<T>> remove(CellDefinition<T> definition)
Cell
with this definition from this set if it is present.T
- the cell JDK typedefinition
- cell definition to removejava.lang.NullPointerException
- if definition
is null
public java.util.Spliterator<Cell<?>> spliterator()
Spliterator
over the cells in this set. This Spliterator
reports
Spliterator.DISTINCT
, Spliterator.NONNULL
, and Spliterator.SIZED
.public java.util.Iterator<Cell<?>> iterator()
Iterator
over the cells in this set. The cells are returned in no particular order.iterator
in interface java.lang.Iterable<Cell<?>>
iterator
in interface java.util.Collection<Cell<?>>
iterator
in interface java.util.Set<Cell<?>>
iterator
in class java.util.AbstractCollection<Cell<?>>
Iterator
over the cells in this set