Package com.terracottatech.store
Interface ComplexData
- All Known Implementing Classes:
StoreListImpl
,StoreMapImpl
public interface ComplexData
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Exception class for "dot" traversal parsing issues. -
Method Summary
Modifier and TypeMethodDescriptionDo a filtering find operation across this object based on the Dot Notation given.boolean
isEmpty()
Is this object empty?boolean
Is this a mutable representation?Make a mutable deep copy of this complex data object.default boolean
notEmpty()
Not empty.static ComplexDataParser
Acquire a parse for a specific reader.static ComplexDataParser
Acquire a parser for a specific stringint
size()
Size (number of elements) in this object.toString
(boolean skipWhitespace) Generate a string representation of this object in the specified format, with the specified compactness.
-
Method Details
-
size
int size()Size (number of elements) in this object.- Returns:
- number of elements.
-
isEmpty
boolean isEmpty()Is this object empty?- Returns:
- true if empty.
-
notEmpty
default boolean notEmpty()Not empty. Inverse of empty. Sugar.- Returns:
- true if not empty
-
isMutable
boolean isMutable()Is this a mutable representation?- Returns:
true
if mutable
-
toString
Generate a string representation of this object in the specified format, with the specified compactness.Native format is TC son, which is a more strongly typed version of JSON. Alternatively, the JSON compatible format grinds everything without a JSON type (chars, byte arrays) to strings, and all three numeric types become just JSON numbers.
- Parameters:
skipWhitespace
- line breaks and indention, or not.- Returns:
- String version of this object.
-
find
Do a filtering find operation across this object based on the Dot Notation given.Dot notation is fairly simple yet powerful.
- '.' by itself matches the current object.
- '.foo' if the top level object is a map, matches the value of the 'foo' key
- '.foo.bar' matches the top level object as a map, then the value at key 'foo', then matches if that value is a map, then matches the value of its key 'bar'. etc.
- map keys for matching can also be expressed with more explicit
- '.[foo bar].[baz]'
- '.["foo\nbar"].baz'
- '.[1]' matches the list entry at index 1 (lists are zero based)
- '.[1:3]' matches the slice from 1 to 3 inclusive.
- finally, a stanza of '.[].' matches all entries. (wildcard)
This allows for reaching inside a nested complex structure and identifying only those pieces of interest. For example: '.employees.[].[first name]' might reach into a map, grab the list at key 'employees', go through every entry in the list, treat as a map, then grab the value of the 'first name' key in each map, this returning a list of every employee's first name.
- Parameters:
dotSpec
- dot specification- Returns:
Selection
of matchingTypedValue
-
parser
Acquire a parse for a specific reader.- Parameters:
in
- Reader for input- Returns:
- parser
-
parser
Acquire a parser for a specific string- Parameters:
in
- String- Returns:
- parser.
-
mutableCopy
ComplexData mutableCopy()Make a mutable deep copy of this complex data object.- Returns:
- mutable copy.
-