Interface StoreMap
- All Superinterfaces:
ComplexData
,Map<String,
TypedValue<?>>
- All Known Implementing Classes:
StoreMapImpl
Type.MAP
objects. It implements a Map
of String to TypedValue
objects.
StoreMaps also have builder-esque fluent methods for specific types, the with() group of methods.
It inherits support for dot traversal find() from ComplexData
Like all ComplexData objects, StoreMap's can be mutable or not; a mutable copy can be made as needed.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.terracottatech.store.ComplexData
ComplexData.DotSpecParseException
-
Method Summary
Modifier and TypeMethodDescriptiondefault CellCollection
Return the contents of this map as aCellCollection
.static StoreMap
Create a StoreMap by parsing from the Reader.static StoreMap
Create a map from aCellSet
.static StoreMap
Create a StoreMap by parsing the String.Make deep copy of this map, ensuring it is mutable.static StoreMap
newMap()
Conanonical constrcutor for new StoreMap instances.default <T> TypedValue<?>
Put a typed value.default StoreMap
Fluently add a Cell to this map.default StoreMap
Fluently add a boolean value to this mapdefault StoreMap
Fluently add a byte array to this mapdefault StoreMap
Fluently add a char value to this mapdefault StoreMap
Fluently add a double value to this mapdefault StoreMap
Fluently add an int value to this mapdefault StoreMap
Fluently add a long to this mapdefault StoreMap
Fluently add a StoreList to this mapdefault StoreMap
Fluently add a StoreMap to this mapdefault StoreMap
with
(String name, TypedValue<?> val) Fluently add a StoreMap to this mapdefault StoreMap
Fluently add a String to this mapMethods inherited from interface com.terracottatech.store.ComplexData
find, isEmpty, isMutable, notEmpty, size, toString
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Method Details
-
newMap
Conanonical constrcutor for new StoreMap instances.- Returns:
- empty store map.
-
mutableCopy
StoreMap mutableCopy()Make deep copy of this map, ensuring it is mutable.- Specified by:
mutableCopy
in interfaceComplexData
- Returns:
- mutable copy of this map
-
asCellCollection
Return the contents of this map as aCellCollection
.- Returns:
- CellCollection
-
put
Put a typed value.- Type Parameters:
T
- the type of the incoming value- Parameters:
name
- the key for this valuetyp
- the {Type
objectvalue
- the value of put put- Returns:
- prior value associated with this key
-
with
Fluently add a StoreMap to this map- Parameters:
name
- the key nameval
- the map- Returns:
- this store map
-
with
Fluently add a boolean value to this map- Parameters:
name
- the key namevalue
- boolean value- Returns:
- this store map
-
with
Fluently add a char value to this map- Parameters:
name
- the key namevalue
- the char value- Returns:
- this store map
-
with
Fluently add a String to this map- Parameters:
name
- the key namevalue
- the string- Returns:
- this store map
-
with
Fluently add a long to this map- Parameters:
name
- the key namevalue
- the long value- Returns:
- this store map
-
with
Fluently add an int value to this map- Parameters:
name
- the key namevalue
- the int value- Returns:
- this store map
-
with
Fluently add a double value to this map- Parameters:
name
- the key namevalue
- the double value- Returns:
- this store map
-
with
Fluently add a byte array to this map- Parameters:
name
- the key namevalue
- the byte array value- Returns:
- this store map
-
with
Fluently add a StoreMap to this map- Parameters:
name
- the key namevalue
- the StoreMap to add- Returns:
- this store map
-
with
Fluently add a StoreList to this map- Parameters:
name
- the key namevalue
- the StoreList value- Returns:
- this store map
-
with
Fluently add a Cell to this map. The name will be used as the key name, the type/value pair will form the TypedValue.- Parameters:
cell
- cell to add- Returns:
- this store map
-
mapOf
Create a StoreMap by parsing the String. SeemapOf(Reader)
for a discussion of parsing issues.- Parameters:
in
- the input String- Returns:
- the store map that was parsed
- Throws:
ComplexDataParseException
- the parse exception
-
mapOf
Create a StoreMap by parsing from the Reader.Parse TCSon formatted maps.
TCSon is a typed extension to JSON, with 'type:value' stanzas instead of just 'value' in JSON. Parsing of generic JSON is generally supported. However, you must take care to handle numerics properly:
- fixed point literals which are between Integer.MAX_VALUE and Integer.MIN_VALUE are typed as Integers
- fixed point literals which are between Long.MAX_VALUE and Long.MIN_VALUE are typed as Longs
- floating point literals become Doubles
- fixed point integer literals using the 'L' suffix are typed as Longs
Also, null values are not allowed as cells, so JSON null values may require reprocessing.
Single character strings become Strings, unless they are enclosed in a single quote, in which chase they become Characters
Complex data objects which are output as via
ComplexData.toString(boolean)
will include type specification as needed to disambiguate values.- Parameters:
in
- Reader. Needs to be UTF-8 charset if you will be handling UTF characters.- Returns:
- the store map that was parsed
- Throws:
ComplexDataParseException
- the parse exception
-
mapOf
Create a map from aCellSet
. Names of cells become keys, type/value pairs become values.- Parameters:
cs
- the cell set- Returns:
- the created store map
-