Package com.terracottatech.store
Class CellSet
- All Implemented Interfaces:
CellCollection
,Iterable<Cell<?>>
,Collection<Cell<?>>
,Set<Cell<?>>
A collection of
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
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.terracottatech.store.CellCollection
CellCollection.SubsetView
-
Field Summary
Fields inherited from interface com.terracottatech.store.CellCollection
CELLS_FIELD_NAME, DEPRECATED_CELLS_FIELD_NAME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds the specifiedCell
to this set if a cell having the same cell name is not already present.Retrieve a cell by name.boolean
Returnstrue
if this set contains the specifiedCell
or another cell having the same name.iterator()
Returns anIterator
over the cells in this set.static CellSet
Creates a new, mutableCellSet
instance containing the specifiedCell
instances.remove
(CellDefinition<T> definition) Removes theCell
with this definition from this set if it is present.boolean
Removes the specifiedCell
.Removes aCell
with the specified name.Cell<?>
Adds the specifiedCell
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()
Spliterator<Cell<?>>
Creates aSpliterator
over the cells in this set.Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, isEmpty, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.terracottatech.store.CellCollection
asStoreMap, get, get, subset, subset
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
CellSet
public CellSet()Creates an new, mutable emptyCellSet
instance. -
CellSet
Creates a new, mutableCellSet
instance containing theCell
s from the specifiedIterable
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.- Parameters:
cells
- theIterable
overCell
instances from which a newCellSet
is created- Throws:
NullPointerException
- ifcells
isnull
orcells
contains anull
element
-
-
Method Details
-
of
Creates a new, mutableCellSet
instance containing the specifiedCell
instances. If more than one cell with the same name is present in the collection, only the last like-named cell is kept.- Parameters:
cells
- theCell
instances for the newCellSet
- Returns:
- a new, mutable
CellSet
containing the specified cells - Throws:
NullPointerException
- ifcells
contains anull
-
cell
Description copied from interface:CellCollection
Retrieve a cell by name. If this record contains a cell whose definition matches the supplied name then the cell is wrapped in anOptional
and returned. If this record contains no matching cell then an emptyOptional
is returned.- Specified by:
cell
in interfaceCellCollection
- Parameters:
name
- cell to retrieve- Returns:
- An
Optional
with the cell or an emptyOptional
if the record contains no matching cell
-
add
Adds the specifiedCell
to this set if a cell having the same cell name is not already present.- Specified by:
add
in interfaceCollection<Cell<?>>
- Specified by:
add
in interfaceSet<Cell<?>>
- Overrides:
add
in classAbstractCollection<Cell<?>>
- Parameters:
cell
- the newCell
to add to this set- Returns:
- if this set did not already contain the specified cell
- Throws:
NullPointerException
- ifcell
isnull
-
set
Adds the specifiedCell
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.- Parameters:
cell
- the newCell
to put into this set- Returns:
- the previous
Cell
having the same name ascell
, if any;null
if a like-named cell is not present - Throws:
NullPointerException
- ifcell
isnull
-
contains
Returnstrue
if this set contains the specifiedCell
or another cell having the same name.- Specified by:
contains
in interfaceCollection<Cell<?>>
- Specified by:
contains
in interfaceSet<Cell<?>>
- Overrides:
contains
in classAbstractCollection<Cell<?>>
- Parameters:
o
-- Returns:
true
if this set contains the specified cell- Throws:
NullPointerException
- ifo
isnull
ClassCastException
- ifo
is not aCell
-
remove
Removes the specifiedCell
.- Specified by:
remove
in interfaceCollection<Cell<?>>
- Specified by:
remove
in interfaceSet<Cell<?>>
- Overrides:
remove
in classAbstractCollection<Cell<?>>
- Parameters:
o
-- Returns:
true
if this set contained the specified cell- Throws:
NullPointerException
- ifo
isnull
ClassCastException
- ifo
is not aCell
-
remove
Removes aCell
with the specified name.- Parameters:
name
- name of cell to be removed- Returns:
- an optional containing the removed cell
- Throws:
NullPointerException
- ifname
isnull
-
remove
Removes theCell
with this definition from this set if it is present.- Type Parameters:
T
- the cell JDK type- Parameters:
definition
- cell definition to remove- Returns:
- an optional containing the removed cell
- Throws:
NullPointerException
- ifdefinition
isnull
-
spliterator
Creates aSpliterator
over the cells in this set. ThisSpliterator
reportsSpliterator.DISTINCT
,Spliterator.NONNULL
, andSpliterator.SIZED
.- Specified by:
spliterator
in interfaceCollection<Cell<?>>
- Specified by:
spliterator
in interfaceIterable<Cell<?>>
- Specified by:
spliterator
in interfaceSet<Cell<?>>
- Returns:
- a
Spliterator
over the cells in this set
-
iterator
Returns anIterator
over the cells in this set. The cells are returned in no particular order. -
size
public int size()- Specified by:
size
in interfaceCollection<Cell<?>>
- Specified by:
size
in interfaceSet<Cell<?>>
- Specified by:
size
in classAbstractCollection<Cell<?>>
- Returns:
-