Class CellCollection.SubsetView

java.lang.Object
java.util.AbstractCollection<Cell<?>>
com.terracottatech.store.CellCollection.SubsetView
All Implemented Interfaces:
CellCollection, Iterable<Cell<?>>, Collection<Cell<?>>
Direct Known Subclasses:
KeyedCellCollection.SubsetView
Enclosing interface:
CellCollection

public static class CellCollection.SubsetView extends AbstractCollection<Cell<?>> implements CellCollection
A subset view of a cell collection.
  • Constructor Details

    • SubsetView

      protected SubsetView(CellCollection of, Set<CellDefinition<?>> definitions)
      Creates a subset view of the given collection showing only the given cells
      Parameters:
      of - the collection to view
      definitions - the cell definitions to select
  • Method Details

    • definitions

      protected Set<CellDefinition<?>> definitions()
      The cell definitions this view selects.
      Returns:
      the selected cell definitions
    • subset

      public CellCollection subset(Set<CellDefinition<?>> definitions)
      Description copied from interface: CellCollection
      Retrieve a subset of cells by their definitions.

      The returned collection is a view. If this collection is mutable any mutations performed on this collection will be visible via the returned view.

      Specified by:
      subset in interface CellCollection
      Parameters:
      definitions - cells to retrieve
      Returns:
      a view of a subset of this collection
    • get

      public <T> Optional<T> get(CellDefinition<T> cellDefinition)
      Description copied from interface: CellCollection
      Retrieve a cell by 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.
      Specified by:
      get in interface CellCollection
      Type Parameters:
      T - the cell JDK type
      Parameters:
      cellDefinition - cell to retrieve
      Returns:
      An Optional with the cell value or an empty Optional if the record contains no matching cell
    • get

      public Optional<?> get(String name)
      Description copied from interface: CellCollection
      Retrieve a cell by name. If this record contains a cell whose definition matches the supplied name 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.
      Specified by:
      get in interface CellCollection
      Parameters:
      name - cell to retrieve
      Returns:
      An Optional with the cell value or an empty Optional if the record contains no matching cell
    • cell

      public Optional<Cell<?>> cell(String name)
      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 an Optional and returned. If this record contains no matching cell then an empty Optional is returned.
      Specified by:
      cell in interface CellCollection
      Parameters:
      name - cell to retrieve
      Returns:
      An Optional with the cell or an empty Optional if the record contains no matching cell
    • spliterator

      public Spliterator<Cell<?>> spliterator()
      Specified by:
      spliterator in interface Collection<Cell<?>>
      Specified by:
      spliterator in interface Iterable<Cell<?>>
    • stream

      public Stream<Cell<?>> stream()
      Specified by:
      stream in interface Collection<Cell<?>>
    • iterator

      public Iterator<Cell<?>> iterator()
      Specified by:
      iterator in interface Collection<Cell<?>>
      Specified by:
      iterator in interface Iterable<Cell<?>>
      Specified by:
      iterator in class AbstractCollection<Cell<?>>
    • size

      public int size()
      Specified by:
      size in interface Collection<Cell<?>>
      Specified by:
      size in class AbstractCollection<Cell<?>>
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<Cell<?>>
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Collection<Cell<?>>
      Overrides:
      equals in class Object