public interface DataView
DataViews always exist within a DataContainer
and can be used
for serialization.
Modifier and Type | Method and Description |
---|---|
boolean |
contains(DataQuery path)
Returns whether this
DataView contains the given path. |
DataContainer |
copy()
Copies this
DataView and all of it's contents into a new
DataContainer . |
DataView |
createView(DataQuery path)
Creates a new
DataView at the desired path. |
DataView |
createView(DataQuery path,
Map<?,?> map)
Creates a new
DataView with the given data at the desired
path. |
Optional<Object> |
get(DataQuery path)
Gets an object from the desired path.
|
Optional<Boolean> |
getBoolean(DataQuery path)
Gets the
Boolean by path, if available. |
Optional<List<Boolean>> |
getBooleanList(DataQuery path)
|
Optional<List<Byte>> |
getByteList(DataQuery path)
|
Optional<List<Character>> |
getCharacterList(DataQuery path)
|
DataContainer |
getContainer()
Gets the parent container of this DataView.
|
DataQuery |
getCurrentPath()
Gets the current path of this
DataView from its root
DataContainer . |
Optional<Double> |
getDouble(DataQuery path)
Gets the
Double by path, if available. |
Optional<List<Double>> |
getDoubleList(DataQuery path)
|
Optional<List<Float>> |
getFloatList(DataQuery path)
|
Optional<Integer> |
getInt(DataQuery path)
Gets the
Integer by path, if available. |
Optional<List<Integer>> |
getIntegerList(DataQuery path)
|
Set<DataQuery> |
getKeys(boolean deep)
Gets a collection containing all keys in this
DataView . |
Optional<List<?>> |
getList(DataQuery path)
Gets the
List of something by path, if available. |
Optional<Long> |
getLong(DataQuery path)
Gets the
Long by path, if available. |
Optional<List<Long>> |
getLongList(DataQuery path)
|
Optional<? extends Map<?,?>> |
getMap(DataQuery path)
Gets the underlying
Map by path, if available. |
Optional<List<Map<?,?>>> |
getMapList(DataQuery path)
|
String |
getName()
Gets the name of this individual
DataView in the path. |
Optional<DataView> |
getParent()
Gets the parent
DataView of this view. |
<T extends DataSerializable> |
getSerializable(DataQuery path,
Class<T> clazz,
SerializationService service)
Gets the
DataSerializable object by path, if available. |
<T extends DataSerializable> |
getSerializableList(DataQuery path,
Class<T> clazz,
SerializationService service)
Gets the
List of DataSerializable by path, if available. |
Optional<List<Short>> |
getShortList(DataQuery path)
|
Optional<String> |
getString(DataQuery path)
Gets the
String by path, if available. |
Optional<List<String>> |
getStringList(DataQuery path)
|
Map<DataQuery,Object> |
getValues(boolean deep)
Gets a Map containing all keys and their values for this
DataView . |
Optional<DataView> |
getView(DataQuery path)
Gets the
DataView by path, if available. |
Optional<List<DataView>> |
getViewList(DataQuery path)
|
DataView |
remove(DataQuery path)
Removes the data associated to the given path relative to this
DataView 's path. |
DataView |
set(DataQuery path,
Object value)
Sets the given Object value according to the given path relative to
this
DataView 's path. |
<E> DataView |
set(Key<? extends BaseValue<E>> key,
E value)
|
DataContainer getContainer()
Every DataView will always have a DataContainer
.
For any DataContainer
, this will return itself.
DataQuery getCurrentPath()
DataView
from its root
DataContainer
.
For any DataContainer
itself, this will return an
empty string as it is the root of the path.
The full path will always include this DataView
s name
at the end of the path.
String getName()
DataView
in the path.
This will always be the final substring of the full path
from getCurrentPath()
.
Optional<DataView> getParent()
DataView
of this view. The parent directly
contains this view according to the getCurrentPath()
.
For any DataContainer
, this will return an absent parent.
Set<DataQuery> getKeys(boolean deep)
DataView
.
If deep is set to true, then this will contain all the keys
within any child DataView
s (and their children, etc).
These will be in a valid path notation for you to use.
If deep is set to false, then this will contain only the keys of any direct children, and not their own children.
deep
- Whether or not to get all children keysMap<DataQuery,Object> getValues(boolean deep)
DataView
.
If deep is set to true, then this will contain all the keys and
values within any child DataView
s (and their children,
etc). These keys will be in a valid path notation for you to use.
If deep is set to false, then this will contain only the keys and values of any direct children, and not their own children.
deep
- Whether or not to get a deep list of all children or notboolean contains(DataQuery path)
DataView
contains the given path.path
- The path relative to this data viewOptional<Object> get(DataQuery path)
path
- The path to the ObjectDataView set(DataQuery path, Object value)
DataView
's path.path
- The path of the object to setvalue
- The value of the data<E> DataView set(Key<? extends BaseValue<E>> key, E value)
E
- The type of valuekey
- The key of the value to setvalue
- The value of the dataDataView remove(DataQuery path)
DataView
's path.
Path can not be emtpy, to remove this DataView
, call
the associated parent to remove this views name.
path
- The path of data to removeDataView createView(DataQuery path)
DataView
at the desired path.
If any data existed at the given path, that data will be
overwritten with the newly constructed DataView
.
path
- The path of the new viewDataView createView(DataQuery path, Map<?,?> map)
DataView
with the given data at the desired
path.
If any data existed at the given path, that data will be overwritten
with the newly constructed DataView
.
path
- The path of the new viewmap
- The data to store in the new viewOptional<DataView> getView(DataQuery path)
DataView
by path, if available.
If a DataView
does not exist, or the data residing at
the path is not an instance of a DataView
, an absent is
returned.
path
- The path of the value to getOptional<? extends Map<?,?>> getMap(DataQuery path)
Map
by path, if available.
If a Map
does not exist, or data residing at the path is not
an instance of a Map
, an absent is returned.
path
- The path of the value to getOptional<Boolean> getBoolean(DataQuery path)
Boolean
by path, if available.
If a Boolean
does not exist, or the data residing at
the path is not an instance of a Boolean
, an absent is
returned.
path
- The path of the value to getOptional<Integer> getInt(DataQuery path)
Integer
by path, if available.
If a Integer
does not exist, or the data residing at
the path is not an instance of a Integer
, an absent is
returned.
path
- The path of the value to getOptional<Long> getLong(DataQuery path)
Long
by path, if available.
If a Long
does not exist, or the data residing at
the path is not an instance of a Long
, an absent is
returned.
path
- The path of the value to getOptional<Double> getDouble(DataQuery path)
Double
by path, if available.
If a Double
does not exist, or the data residing at
the path is not an instance of a Double
, an absent is
returned.
path
- The path of the value to getOptional<String> getString(DataQuery path)
String
by path, if available.
If a String
does not exist, or the data residing at
the path is not an instance of a String
, an absent is
returned.
path
- The path of the value to getOptional<List<?>> getList(DataQuery path)
List
of something by path, if available.
If a List
of something does not exist, or the data
residing at the path is not an instance of a List
of something,
an absent is returned.
path
- The path of the value to getOptional<List<String>> getStringList(DataQuery path)
List
of String
by path, if available.
If a List
of String
does not exist, or the data
residing at the path is not an instance of a List
of
String
, an absent is returned.
path
- The path of the value to getOptional<List<Character>> getCharacterList(DataQuery path)
List
of Character
by path, if available.
If a List
of Character
does not exist, or the data
residing at the path is not an instance of a List
of
Character
, an absent is returned.
path
- The path of the value to getOptional<List<Boolean>> getBooleanList(DataQuery path)
List
of Boolean
by path, if available.
If a List
of Boolean
does not exist, or the data
residing at the path is not an instance of a List
of
Boolean
, an absent is returned.
path
- The path of the value to getOptional<List<Byte>> getByteList(DataQuery path)
List
of Byte
by path, if available.
If a List
of Byte
does not exist, or the data
residing at the path is not an instance of a List
of
Byte
, an absent is returned.
path
- The path of the value to getOptional<List<Short>> getShortList(DataQuery path)
List
of Short
by path, if available.
If a List
of Short
does not exist, or the data
residing at the path is not an instance of a List
of
Short
, an absent is returned.
path
- The path of the value to getOptional<List<Integer>> getIntegerList(DataQuery path)
List
of Integer
by path, if available.
If a List
of Integer
does not exist, or the data
residing at the path is not an instance of a List
of
Integer
, an absent is returned.
path
- The path of the value to getOptional<List<Long>> getLongList(DataQuery path)
List
of Long
by path, if available.
If a List
of Long
does not exist, or the data
residing at the path is not an instance of a List
of
Long
, an absent is returned.
path
- The path of the value to getOptional<List<Float>> getFloatList(DataQuery path)
List
of Float
by path, if available.
If a List
of Float
does not exist, or the data
residing at the path is not an instance of a List
of
Float
, an absent is returned.
path
- The path of the value to getOptional<List<Double>> getDoubleList(DataQuery path)
List
of Double
by path, if available.
If a List
of Double
does not exist, or the data
residing at the path is not an instance of a List
of
Double
, an absent is returned.
path
- The path of the value to getOptional<List<Map<?,?>>> getMapList(DataQuery path)
List
of Map
by path, if available.
If a List
of Map
does not exist, or the data
residing at the path is not an instance of a List
of
Map
, an absent is returned.
path
- The path of the value to getOptional<List<DataView>> getViewList(DataQuery path)
List
of DataView
by path, if available.
If a List
of DataView
does not exist, or the data
residing at the path is not an instance of a List
of
DataView
, an absent is returned.
path
- The path of the value to get<T extends DataSerializable> Optional<T> getSerializable(DataQuery path, Class<T> clazz, SerializationService service)
DataSerializable
object by path, if available.
If a DataSerializable
exists, but is not the proper class
type, or there is no data at the path given, an absent is returned.
It is important that the SerializationService
provided is
the same one that has registered many of the
DataBuilder
s to ensure the DataSerializable
requested can be returned.
T
- The type of DataSerializable
objectpath
- The path of the value to getclazz
- The class of the DataSerializable
service
- The serialization service to use for retrieving data
serializable builders<T extends DataSerializable> Optional<List<T>> getSerializableList(DataQuery path, Class<T> clazz, SerializationService service)
List
of DataSerializable
by path, if available.
If a List
exists, but the contents of the list are not
considered DataSerializable
or are not of the proper type of
DataSerializable
, an absent is returned.
It is important that the SerializationService
provided is
the same one that has registered many of the
DataBuilder
s to ensure the DataSerializable
requested can be returned.
T
- The type of DataSerializable
objectpath
- The path of the list value to getclazz
- The class of the DataSerializable
service
- The serialization service to use for retrieving data
serializable buildersDataContainer copy()
DataView
and all of it's contents into a new
DataContainer
.
Note that the copy will not have the same path as this
DataView
since it will be constructed with the top level path
being itself.