Package com.terracottatech.store
Class CellSet
- All Implemented Interfaces:
CellCollection,Iterable<Cell<?>>,Collection<Cell<?>>,Set<Cell<?>>
A collection of
Cells 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 TypeMethodDescriptionbooleanAdds the specifiedCellto this set if a cell having the same cell name is not already present.Retrieve a cell by name.booleanReturnstrueif this set contains the specifiedCellor another cell having the same name.iterator()Returns anIteratorover the cells in this set.static CellSetCreates a new, mutableCellSetinstance containing the specifiedCellinstances.remove(CellDefinition<T> definition) Removes theCellwith this definition from this set if it is present.booleanRemoves the specifiedCell.Removes aCellwith the specified name.Cell<?>Adds the specifiedCellto 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.intsize()Spliterator<Cell<?>>Creates aSpliteratorover the cells in this set.Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, isEmpty, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.terracottatech.store.CellCollection
asStoreMap, get, get, subset, subsetMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
CellSet
public CellSet()Creates an new, mutable emptyCellSetinstance. -
CellSet
Creates a new, mutableCellSetinstance containing theCells from the specifiedIterablein 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- theIterableoverCellinstances from which a newCellSetis created- Throws:
NullPointerException- ifcellsisnullorcellscontains anullelement
-
-
Method Details
-
of
Creates a new, mutableCellSetinstance containing the specifiedCellinstances. If more than one cell with the same name is present in the collection, only the last like-named cell is kept.- Parameters:
cells- theCellinstances for the newCellSet- Returns:
- a new, mutable
CellSetcontaining the specified cells - Throws:
NullPointerException- ifcellscontains anull
-
cell
Description copied from interface:CellCollectionRetrieve a cell by name. If this record contains a cell whose definition matches the supplied name then the cell is wrapped in anOptionaland returned. If this record contains no matching cell then an emptyOptionalis returned.- Specified by:
cellin interfaceCellCollection- Parameters:
name- cell to retrieve- Returns:
- An
Optionalwith the cell or an emptyOptionalif the record contains no matching cell
-
add
Adds the specifiedCellto this set if a cell having the same cell name is not already present.- Specified by:
addin interfaceCollection<Cell<?>>- Specified by:
addin interfaceSet<Cell<?>>- Overrides:
addin classAbstractCollection<Cell<?>>- Parameters:
cell- the newCellto add to this set- Returns:
- if this set did not already contain the specified cell
- Throws:
NullPointerException- ifcellisnull
-
set
Adds the specifiedCellto 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 newCellto put into this set- Returns:
- the previous
Cellhaving the same name ascell, if any;nullif a like-named cell is not present - Throws:
NullPointerException- ifcellisnull
-
contains
Returnstrueif this set contains the specifiedCellor another cell having the same name.- Specified by:
containsin interfaceCollection<Cell<?>>- Specified by:
containsin interfaceSet<Cell<?>>- Overrides:
containsin classAbstractCollection<Cell<?>>- Parameters:
o-- Returns:
trueif this set contains the specified cell- Throws:
NullPointerException- ifoisnullClassCastException- ifois not aCell
-
remove
Removes the specifiedCell.- Specified by:
removein interfaceCollection<Cell<?>>- Specified by:
removein interfaceSet<Cell<?>>- Overrides:
removein classAbstractCollection<Cell<?>>- Parameters:
o-- Returns:
trueif this set contained the specified cell- Throws:
NullPointerException- ifoisnullClassCastException- ifois not aCell
-
remove
Removes aCellwith the specified name.- Parameters:
name- name of cell to be removed- Returns:
- an optional containing the removed cell
- Throws:
NullPointerException- ifnameisnull
-
remove
Removes theCellwith 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- ifdefinitionisnull
-
spliterator
Creates aSpliteratorover the cells in this set. ThisSpliteratorreportsSpliterator.DISTINCT,Spliterator.NONNULL, andSpliterator.SIZED.- Specified by:
spliteratorin interfaceCollection<Cell<?>>- Specified by:
spliteratorin interfaceIterable<Cell<?>>- Specified by:
spliteratorin interfaceSet<Cell<?>>- Returns:
- a
Spliteratorover the cells in this set
-
iterator
Returns anIteratorover the cells in this set. The cells are returned in no particular order. -
size
public int size()- Specified by:
sizein interfaceCollection<Cell<?>>- Specified by:
sizein interfaceSet<Cell<?>>- Specified by:
sizein classAbstractCollection<Cell<?>>- Returns:
-