public abstract class ComplexData extends Object
ComplexOutput
Commands typically result in simple types, however some of the commands could return complex nested structures. In these
cases, and with the help of a ComplexDataParser, the data gathered by the ComplexOutput could be parsed to a
domain object.
An complex data object could only be an aggregate data type as per the RESP2 and RESP3 protocol definitions. Its contents, however, could be both the simple and aggregate data types.
For RESP2 the only possible aggregation is an array. RESP2 commands could also return sets (obviously, by simply making sure the elements of the array are unique) or maps (by sending the keys as odd elements and their values as even elements in the right order one after another.
For RESP3 all the three aggregate types are supported (and indicated with special characters when the result is returned by the server).
Aggregate data types could also be nested by using the storeObject(Object) call.
Implementations of this class override the getDynamicSet(), getDynamicList() and
getDynamicMap() methods to return the data received in the server in a implementation of the Collections
framework. If a given implementation could not do the conversion in a meaningful way an UnsupportedOperationException
would be thrown.
ComplexOutput,
ArrayComplexData,
SetComplexData,
MapComplexData| Constructor and Description |
|---|
ComplexData() |
| Modifier and Type | Method and Description |
|---|---|
List<Object> |
getDynamicList()
Returns the aggregate data in a
List form. |
Map<Object,Object> |
getDynamicMap()
Returns the aggregate data in a
Map form. |
Set<Object> |
getDynamicSet()
Returns the aggregate data in a
Set form. |
boolean |
isList()
Returns true if the underlying data structure is a
List
Does not mean that calling getDynamicList() would not throw an exception. |
boolean |
isMap()
Returns true if the underlying data structure is a
Map
Does not mean that calling getDynamicMap() would not throw an exception. |
boolean |
isSet()
Returns true if the underlying data structure is a
Set
Does not mean that calling getDynamicSet() would not throw an exception. |
void |
store(boolean value)
Store a
boolean value in the underlying data structure |
void |
store(double value)
Store a
double value in the underlying data structure |
void |
store(long value)
Store a
long value in the underlying data structure |
void |
store(String value) |
abstract void |
storeObject(Object value)
Store an
Object value in the underlying data structure. |
public void store(long value)
long value in the underlying data structurevalue - the value to storepublic void store(double value)
double value in the underlying data structurevalue - the value to storepublic void store(boolean value)
boolean value in the underlying data structurevalue - the value to storepublic abstract void storeObject(Object value)
Object value in the underlying data structure. This method should be used when nesting one instance of
ComplexData inside anothervalue - the value to storepublic void store(String value)
public List<Object> getDynamicList()
List form. If the underlying implementation could not convert the data structure
to a List then an UnsupportedOperationException would be thrown.public Set<Object> getDynamicSet()
Set form. If the underlying implementation could not convert the data structure
to a Set then an UnsupportedOperationException would be thrown.public Map<Object,Object> getDynamicMap()
Map form. If the underlying implementation could not convert the data structure
to a Map then an UnsupportedOperationException would be thrown.public boolean isMap()
Map
Does not mean that calling getDynamicMap() would not throw an exception. Implementations might decide to return
a representation of the data as a map, even if the underlying data structure is not a map.
Mappublic boolean isSet()
Set
Does not mean that calling getDynamicSet() would not throw an exception. Implementations might decide to return
a representation of the data as a set, even if the underlying data structure is not a set.
Setpublic boolean isList()
List
Does not mean that calling getDynamicList() would not throw an exception. Implementations might decide to return
a representation of the data as a list, even if the underlying data structure is not a list.
ListCopyright © 2025 lettuce.io. All rights reserved.