public interface DataView
DataViews always exist within a DataContainer
and can be used
for serialization.
Modifier and Type | Interface and Description |
---|---|
static class |
DataView.SafetyMode
The safety mode of the container.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(DataQuery path)
Returns whether this
DataView contains the given path. |
boolean |
contains(DataQuery path,
DataQuery... paths)
|
default boolean |
contains(Key<?> key)
|
default boolean |
contains(Key<?> key,
Key<?>... keys)
|
DataContainer |
copy()
Copies this
DataView and all of it's contents into a new
DataContainer . |
DataContainer |
copy(DataView.SafetyMode safety)
Copies this
DataView and all of it's contents into a new
DataContainer with the given safety mode. |
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<Byte> |
getByte(DataQuery path)
Gets the
Byte by path, if available. |
Optional<List<Byte>> |
getByteList(DataQuery path)
|
<T extends CatalogType> |
getCatalogType(DataQuery path,
Class<T> catalogType)
Gets the
CatalogType object by path, if available. |
<T extends CatalogType> |
getCatalogTypeList(DataQuery path,
Class<T> catalogType)
Gets the
List of CatalogType s by path, if available. |
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<Float> |
getFloat(DataQuery path)
Gets the
Float by path, if available. |
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. |
<T> Optional<T> |
getObject(DataQuery path,
Class<T> objectClass)
Gets the
Object object by path, if available. |
<T> Optional<List<T>> |
getObjectList(DataQuery path,
Class<T> objectClass)
Gets the
List of DataSerializable by path, if available. |
Optional<DataView> |
getParent()
Gets the parent
DataView of this view. |
DataView.SafetyMode |
getSafetyMode()
Gets the
DataView.SafetyMode of this data view. |
<T extends DataSerializable> |
getSerializable(DataQuery path,
Class<T> clazz)
Gets the
DataSerializable object by path, if available. |
<T extends DataSerializable> |
getSerializableList(DataQuery path,
Class<T> clazz)
Gets the
List of DataSerializable by path, if available. |
Optional<Short> |
getShort(DataQuery path)
Gets the
Short 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)
|
boolean |
isEmpty()
Gets if this view contains no data.
|
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 viewboolean contains(DataQuery path, DataQuery... paths)
path
- The path relative to this data viewpaths
- The additional paths to checkdefault boolean contains(Key<?> key)
key
- The key to get the data path relative to this data viewdefault boolean contains(Key<?> key, Key<?>... keys)
key
- The key to get the data path relative to this data viewkeys
- The additional keys to checkOptional<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 empty, 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<Short> getShort(DataQuery path)
Short
by path, if available.
If a Short
does not exist, or the data residing at
the path is not an instance of a Short
, an absent is
returned.
path
- The path of the value to getOptional<Byte> getByte(DataQuery path)
Byte
by path, if available.
If a Byte
does not exist, or the data residing at
the path is not an instance of a Byte
, 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<Float> getFloat(DataQuery path)
Float
by path, if available.
If a Float
does not exist, or the data residing at
the path is not an instance of a Float
, 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)
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 DataManager
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
<T extends DataSerializable> Optional<List<T>> getSerializableList(DataQuery path, Class<T> clazz)
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 DataManager
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
<T> Optional<T> getObject(DataQuery path, Class<T> objectClass)
Object
object by path, if available.
If a Object
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 DataManager
provided is
the same one that has registered many of the
DataTranslator
s to ensure the DataSerializable
requested can be returned.
<T> Optional<List<T>> getObjectList(DataQuery path, Class<T> objectClass)
List
of DataSerializable
by path, if available.
If a List
exists, but the contents of the list are not
considered DataTranslator
"able" or are not of the proper type of
DataTranslator
, an absent is returned.
It is important that the DataManager
provided is
the same one that has registered many of the
DataTranslator
s to ensure the Object
requested can be returned.
<T extends CatalogType> Optional<T> getCatalogType(DataQuery path, Class<T> catalogType)
CatalogType
object by path, if available.
If a CatalogType
exists, but is not named properly, not
existing in a registry, or simply an invalid value will return
an empty value.
T
- The type of dummypath
- The path of the value to getcatalogType
- The class of the dummy type<T extends CatalogType> Optional<List<T>> getCatalogTypeList(DataQuery path, Class<T> catalogType)
List
of CatalogType
s by path, if available.
If a List
exists, but contents of the list are not
considered CatalogType
s or are not of the proper type
of CatalogType
, an absent is returned.
T
- The type of dummy typepath
- The path of the list value to getcatalogType
- The class of the dummy typeDataContainer 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.
DataContainer copy(DataView.SafetyMode safety)
DataView
and all of it's contents into a new
DataContainer
with the given safety mode.
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.
safety
- The safety mode of the copyboolean isEmpty()
DataView.SafetyMode getSafetyMode()
DataView.SafetyMode
of this data view.