Package com.terracottatech.store
Interface KeyedCellCollection<K extends Comparable<K>>
- All Superinterfaces:
CellCollection
,Collection<Cell<?>>
,Iterable<Cell<?>>
- All Known Subinterfaces:
Record<K>
- All Known Implementing Classes:
AbstractRecord
,KeyedCellCollection.Detached
,KeyedCellCollection.SubsetView
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
KeyedCellCollection.Detached<K extends Comparable<K>>
An isolated (from any dataset) keyed cell collection.static class
KeyedCellCollection.SubsetView<K extends Comparable<K>>
A subset view of a keyed cell collection. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Deprecated.static final String
The JSON/TSON field name for the key.Fields inherited from interface com.terracottatech.store.CellCollection
CELLS_FIELD_NAME, DEPRECATED_CELLS_FIELD_NAME
-
Method Summary
Modifier and TypeMethodDescriptiondefault StoreMap
Return this keyed cell collection as a complex data typeboolean
Indicates whether some object is equal to thisKeyedCellCollection
.getKey()
Returns the key for this collection.int
hashCode()
Returns a hash code value for this collection.static KeyedCellCollection<?>
Create a keyed cell collection from the givenStoreMap
.static <K extends Comparable<K>>
KeyedCellCollection<K>Create a keyed cell collection with the givn from the givenStoreMap
.static <K extends Comparable<K>>
KeyedCellCollection<K>Create a keyed cell collection with the given key and cells.static <K extends Comparable<K>>
KeyedCellCollection<K>Create a keyed cell collection with the given key and cells.default KeyedCellCollection<K>
subset
(CellDefinition<?>... definitions) Retrieve a subset of cells by their definitions.default KeyedCellCollection<K>
subset
(Set<CellDefinition<?>> definitions) Retrieve a subset of cells by their definitions.static <K extends Comparable<K>>
BuildableFunction<KeyedCellCollection<K>,KeyedCellCollection<K>> subsetFunction
(CellDefinition<?>... definitions) Returns a function that maps keyed cell collections to subsets containing only the given cell definitions.static <K extends Comparable<K>>
BuildableFunction<KeyedCellCollection<K>,KeyedCellCollection<K>> subsetFunction
(Set<CellDefinition<?>> definitions) Returns a function that maps keyed cell collections to subsets containing only the given cell definitions.Methods inherited from interface com.terracottatech.store.CellCollection
cell, get, get
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
KEY_FIELD_NAME
The JSON/TSON field name for the key.- See Also:
-
DEPRECATED_KEY_FIELD_NAME
Deprecated.output now usesKEY_FIELD_NAME
The old JSON/TSON field name for the key.- See Also:
-
-
Method Details
-
getKey
K getKey()Returns the key for this collection.- Returns:
- the collection key
-
equals
Indicates whether some object is equal to thisKeyedCellCollection
.While conforming to the general contract established for
Object.equals
, implementations forKeyedCellCollection
subclasses will consider the value forgetKey
and the cells contained in this instance.- Specified by:
equals
in interfaceCollection<K extends Comparable<K>>
- Overrides:
equals
in classObject
- See Also:
-
hashCode
int hashCode()Returns a hash code value for this collection.While conforming to the general contract established for
Object.hashCode
, in concert with#equals
, implementations forKeyedCellCollection
subclasses will consider the value forgetKey
and the cells contained in this instance.- Specified by:
hashCode
in interfaceCollection<K extends Comparable<K>>
- Overrides:
hashCode
in classObject
- Returns:
- a hash code for this instance.
- See Also:
-
subset
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 interfaceCellCollection
- Parameters:
definitions
- cells to retrieve- Returns:
- a view of a subset of this collection
-
subset
Description copied from interface:CellCollection
Retrieve a subset of cells by their definitions.- Specified by:
subset
in interfaceCellCollection
- Parameters:
definitions
- cells to retrieve- Returns:
- a view of a subset of this collection
- See Also:
-
asStoreMap
Return this keyed cell collection as a complex data typeThe JSON representation of a keyed cell collection is:
{ "key": "keyValue", "cells": { "cellName":"cellValue", ... } }
- Specified by:
asStoreMap
in interfaceCellCollection
- Returns:
- keyed complex map
-
subsetFunction
static <K extends Comparable<K>> BuildableFunction<KeyedCellCollection<K>,KeyedCellCollection<K>> subsetFunction(Set<CellDefinition<?>> definitions) Returns a function that maps keyed cell collections to subsets containing only the given cell definitions.- Type Parameters:
K
- the key type- Parameters:
definitions
- cell definitions to select- Returns:
- a subset projection function
-
subsetFunction
static <K extends Comparable<K>> BuildableFunction<KeyedCellCollection<K>,KeyedCellCollection<K>> subsetFunction(CellDefinition<?>... definitions) Returns a function that maps keyed cell collections to subsets containing only the given cell definitions.- Type Parameters:
K
- the key type- Parameters:
definitions
- cell definitions to select- Returns:
- a subset projection function
-
of
Create a keyed cell collection with the given key and cells.- Type Parameters:
K
- the key type- Parameters:
key
- the collection keycells
- the contained cells- Returns:
- a keyed cell collection
-
of
Create a keyed cell collection with the given key and cells.- Type Parameters:
K
- the key type- Parameters:
key
- the collection keycells
- the contained cells- Returns:
- a keyed cell collection
-
of
Create a keyed cell collection from the givenStoreMap
.The map must contain:
- a key mapped to
KEY_FIELD_NAME
, orDEPRECATED_KEY_FIELD_NAME
- a map of cells mapped to
CellCollection.CELLS_FIELD_NAME
, orCellCollection.DEPRECATED_CELLS_FIELD_NAME
ComplexDataParseException
will be thrown.- Parameters:
map
- the keyed cell collection as a map- Returns:
- a keyed cell collection
- Throws:
ComplexDataParseException
- if the map doesn't contain an encoded keyed cell collection- See Also:
- a key mapped to
-
of
static <K extends Comparable<K>> KeyedCellCollection<K> of(Type<K> keyType, StoreMap map) throws ComplexDataParseException Create a keyed cell collection with the givn from the givenStoreMap
.The map must contain:
- a key of type
keyType
mapped toKEY_FIELD_NAME
, orDEPRECATED_KEY_FIELD_NAME
- a map of cells mapped to
CellCollection.CELLS_FIELD_NAME
, orCellCollection.DEPRECATED_CELLS_FIELD_NAME
-
If the map contents doesn't meet these requirements then a
ComplexDataParseException
will be thrown.- Type Parameters:
K
- the key type- Parameters:
keyType
- the expected key typemap
- the keyed cell collection as a map- Returns:
- a keyed cell collection
- Throws:
ComplexDataParseException
- See Also:
- a key of type
-
KEY_FIELD_NAME