Interface DataView
-
- All Known Subinterfaces:
DataContainer
public interface DataView
Represents an object of data represented by a map.DataViews always exist within a
DataContainer
and can be used for serialization.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DataView.SafetyMode
The safety mode of the container.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description DataContainer
container()
Gets the parent container of this DataView.boolean
contains(DataQuery path)
Returns whether thisDataView
contains the given path.boolean
contains(DataQuery path, DataQuery... paths)
DataContainer
copy()
Copies thisDataView
and all of it's contents into a newDataContainer
.DataContainer
copy(DataView.SafetyMode safety)
Copies thisDataView
and all of it's contents into a newDataContainer
with the given safety mode.DataView
createView(DataQuery path)
Creates a newDataView
at the desired path.DataView
createView(DataQuery path, Map<?,?> map)
Creates a newDataView
with the given data at the desired path.DataQuery
currentPath()
Gets the current path of thisDataView
from its rootDataContainer
.Optional<Object>
get(DataQuery path)
Gets an object from the desired path.Optional<Boolean>
getBoolean(DataQuery path)
Gets theBoolean
by path, if available.Optional<List<Boolean>>
getBooleanList(DataQuery path)
Optional<Byte>
getByte(DataQuery path)
Gets theByte
by path, if available.Optional<List<Byte>>
getByteList(DataQuery path)
Optional<List<Character>>
getCharacterList(DataQuery path)
<E,V extends Value<E>>
Optional<Key<V>>getDataKey(DataQuery path)
Gets thekey
by path, if available.Optional<List<Key<? extends Value<?>>>>
getDataKeyList(DataQuery path)
Optional<Double>
getDouble(DataQuery path)
Gets theDouble
by path, if available.Optional<List<Double>>
getDoubleList(DataQuery path)
Optional<Float>
getFloat(DataQuery path)
Gets theFloat
by path, if available.Optional<List<Float>>
getFloatList(DataQuery path)
Optional<Integer>
getInt(DataQuery path)
Gets theInteger
by path, if available.Optional<List<Integer>>
getIntegerList(DataQuery path)
Optional<List<?>>
getList(DataQuery path)
Gets theList
of something by path, if available.Optional<Long>
getLong(DataQuery path)
Gets theLong
by path, if available.Optional<List<Long>>
getLongList(DataQuery path)
Optional<? extends Map<?,?>>
getMap(DataQuery path)
Gets the underlyingMap
by path, if available.Optional<List<Map<?,?>>>
getMapList(DataQuery path)
<T> Optional<T>
getObject(DataQuery path, Class<T> objectClass)
Gets theObject
object by path, if available.<T> Optional<List<T>>
getObjectList(DataQuery path, Class<T> objectClass)
Gets theList
ofDataSerializable
by path, if available.default <T> Optional<T>
getRegistryValue(DataQuery path, RegistryType<T> registryType)
Gets thevalue
by path, if available, from the global registry.<T> Optional<T>
getRegistryValue(DataQuery path, RegistryType<T> registryType, RegistryHolder holder)
Gets thevalue
by path, if available.default <T> Optional<List<T>>
getRegistryValueList(DataQuery path, RegistryType<T> registryType)
<T> Optional<List<T>>
getRegistryValueList(DataQuery path, RegistryType<T> registryType, RegistryHolder holder)
default Optional<ResourceKey>
getResourceKey(DataQuery path)
Gets thekey
by path, if available.default Optional<List<ResourceKey>>
getResourceKeyList(DataQuery path)
<T extends DataSerializable>
Optional<T>getSerializable(DataQuery path, Class<T> clazz)
Gets theDataSerializable
object by path, if available.<T extends DataSerializable>
Optional<List<T>>getSerializableList(DataQuery path, Class<T> clazz)
Gets theList
ofDataSerializable
by path, if available.Optional<Short>
getShort(DataQuery path)
Gets theShort
by path, if available.Optional<List<Short>>
getShortList(DataQuery path)
Optional<String>
getString(DataQuery path)
Gets theString
by path, if available.Optional<List<String>>
getStringList(DataQuery path)
Optional<DataView>
getView(DataQuery path)
Gets theDataView
by path, if available.Optional<List<DataView>>
getViewList(DataQuery path)
boolean
isEmpty()
Gets if this view contains no data.Set<DataQuery>
keys(boolean deep)
Gets a collection containing all keys in thisDataView
.String
name()
Gets the name of this individualDataView
in the path.Optional<DataView>
parent()
Gets the parentDataView
of this view.DataView
remove(DataQuery path)
Removes the data associated to the given path relative to thisDataView
's path.DataView.SafetyMode
safetyMode()
Gets theDataView.SafetyMode
of this data view.DataView
set(DataQuery path, Object value)
Sets the given Object value according to the given path relative to thisDataView
's path.Map<DataQuery,Object>
values(boolean deep)
Gets a Map containing all keys and their values for thisDataView
.
-
-
-
Method Detail
-
container
DataContainer container()
Gets the parent container of this DataView.Every DataView will always have a
DataContainer
.For any
DataContainer
, this will return itself.- Returns:
- The parent container
-
currentPath
DataQuery currentPath()
Gets the current path of thisDataView
from its rootDataContainer
.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.- Returns:
- The path of this view originating from the root
-
name
String name()
Gets the name of this individualDataView
in the path.This will always be the final substring of the full path from
currentPath()
.- Returns:
- The name of this DataView
-
parent
Optional<DataView> parent()
Gets the parentDataView
of this view. The parent directly contains this view according to thecurrentPath()
.For any
DataContainer
, this will return an absent parent.- Returns:
- The parent data view containing this view
-
keys
Set<DataQuery> keys(boolean deep)
Gets a collection containing all keys in thisDataView
.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.
- Parameters:
deep
- Whether or not to get all children keys- Returns:
- A set of current keys in this container
-
values
Map<DataQuery,Object> values(boolean deep)
Gets a Map containing all keys and their values for thisDataView
.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.
- Parameters:
deep
- Whether or not to get a deep list of all children or not- Returns:
- Map of keys and values of this container
-
contains
boolean contains(DataQuery path)
Returns whether thisDataView
contains the given path.- Parameters:
path
- The path relative to this data view- Returns:
- True if the path exists
-
contains
boolean contains(DataQuery path, DataQuery... paths)
- Parameters:
path
- The path relative to this data viewpaths
- The additional paths to check- Returns:
- True if all paths exist
-
get
Optional<Object> get(DataQuery path)
Gets an object from the desired path. If the path is not defined, an absent Optional is returned.- Parameters:
path
- The path to the Object- Returns:
- The Object, if available
-
set
DataView set(DataQuery path, Object value)
Sets the given Object value according to the given path relative to thisDataView
's path.- Parameters:
path
- The path of the object to setvalue
- The value of the data- Returns:
- This view, for chaining
-
remove
DataView remove(DataQuery path)
Removes the data associated to the given path relative to thisDataView
's path.Path can not be empty, to remove this
DataView
, call the associated parent to remove this views name.- Parameters:
path
- The path of data to remove- Returns:
- This view, for chaining
-
createView
DataView createView(DataQuery path)
Creates a newDataView
at the desired path.If any data existed at the given path, that data will be overwritten with the newly constructed
DataView
.- Parameters:
path
- The path of the new view- Returns:
- The newly created view
-
createView
DataView createView(DataQuery path, Map<?,?> map)
Creates a newDataView
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
.- Parameters:
path
- The path of the new viewmap
- The data to store in the new view- Returns:
- The new view
-
getView
Optional<DataView> getView(DataQuery path)
Gets theDataView
by path, if available.If a
DataView
does not exist, or the data residing at the path is not an instance of aDataView
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The data view, if available
-
getMap
Optional<? extends Map<?,?>> getMap(DataQuery path)
Gets the underlyingMap
by path, if available.If a
Map
does not exist, or data residing at the path is not an instance of aMap
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The map, if available
-
getBoolean
Optional<Boolean> getBoolean(DataQuery path)
Gets theBoolean
by path, if available.If a
Boolean
does not exist, or the data residing at the path is not an instance of aBoolean
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The boolean, if available
-
getShort
Optional<Short> getShort(DataQuery path)
Gets theShort
by path, if available.If a
Short
does not exist, or the data residing at the path is not an instance of aShort
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The boolean, if available
-
getByte
Optional<Byte> getByte(DataQuery path)
Gets theByte
by path, if available.If a
Byte
does not exist, or the data residing at the path is not an instance of aByte
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The boolean, if available
-
getInt
Optional<Integer> getInt(DataQuery path)
Gets theInteger
by path, if available.If a
Integer
does not exist, or the data residing at the path is not an instance of aInteger
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The integer, if available
-
getLong
Optional<Long> getLong(DataQuery path)
Gets theLong
by path, if available.If a
Long
does not exist, or the data residing at the path is not an instance of aLong
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The long, if available
-
getFloat
Optional<Float> getFloat(DataQuery path)
Gets theFloat
by path, if available.If a
Float
does not exist, or the data residing at the path is not an instance of aFloat
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The boolean, if available
-
getDouble
Optional<Double> getDouble(DataQuery path)
Gets theDouble
by path, if available.If a
Double
does not exist, or the data residing at the path is not an instance of aDouble
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The double, if available
-
getString
Optional<String> getString(DataQuery path)
Gets theString
by path, if available.If a
String
does not exist, or the data residing at the path is not an instance of aString
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The string, if available
-
getResourceKey
default Optional<ResourceKey> getResourceKey(DataQuery path)
Gets thekey
by path, if available.- Parameters:
path
- The path of the value to get- Returns:
- The key, if available
-
getResourceKeyList
default Optional<List<ResourceKey>> getResourceKeyList(DataQuery path)
- Parameters:
path
- The path of the value to get- Returns:
- The list of keys, if available
-
getList
Optional<List<?>> getList(DataQuery path)
Gets theList
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 aList
of something, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list, if available
-
getStringList
Optional<List<String>> getStringList(DataQuery path)
Gets theList
ofString
by path, if available.If a
List
ofString
does not exist, or the data residing at the path is not an instance of aList
ofString
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of strings, if available
-
getCharacterList
Optional<List<Character>> getCharacterList(DataQuery path)
Gets theList
ofCharacter
by path, if available.If a
List
ofCharacter
does not exist, or the data residing at the path is not an instance of aList
ofCharacter
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of characters, if available
-
getBooleanList
Optional<List<Boolean>> getBooleanList(DataQuery path)
Gets theList
ofBoolean
by path, if available.If a
List
ofBoolean
does not exist, or the data residing at the path is not an instance of aList
ofBoolean
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of booleans, if available
-
getByteList
Optional<List<Byte>> getByteList(DataQuery path)
Gets theList
ofByte
by path, if available.If a
List
ofByte
does not exist, or the data residing at the path is not an instance of aList
ofByte
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of bytes, if available
-
getShortList
Optional<List<Short>> getShortList(DataQuery path)
Gets theList
ofShort
by path, if available.If a
List
ofShort
does not exist, or the data residing at the path is not an instance of aList
ofShort
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of shorts, if available
-
getIntegerList
Optional<List<Integer>> getIntegerList(DataQuery path)
Gets theList
ofInteger
by path, if available.If a
List
ofInteger
does not exist, or the data residing at the path is not an instance of aList
ofInteger
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of integers, if available
-
getLongList
Optional<List<Long>> getLongList(DataQuery path)
Gets theList
ofLong
by path, if available.If a
List
ofLong
does not exist, or the data residing at the path is not an instance of aList
ofLong
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of longs, if available
-
getFloatList
Optional<List<Float>> getFloatList(DataQuery path)
Gets theList
ofFloat
by path, if available.If a
List
ofFloat
does not exist, or the data residing at the path is not an instance of aList
ofFloat
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of floats, if available
-
getDoubleList
Optional<List<Double>> getDoubleList(DataQuery path)
Gets theList
ofDouble
by path, if available.If a
List
ofDouble
does not exist, or the data residing at the path is not an instance of aList
ofDouble
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of doubles, if available
-
getMapList
Optional<List<Map<?,?>>> getMapList(DataQuery path)
Gets theList
ofMap
by path, if available.If a
List
ofMap
does not exist, or the data residing at the path is not an instance of aList
ofMap
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of maps, if available
-
getViewList
Optional<List<DataView>> getViewList(DataQuery path)
Gets theList
ofDataView
by path, if available.If a
List
ofDataView
does not exist, or the data residing at the path is not an instance of aList
ofDataView
, an absent is returned.- Parameters:
path
- The path of the value to get- Returns:
- The list of data views, if available
-
getSerializable
<T extends DataSerializable> Optional<T> getSerializable(DataQuery path, Class<T> clazz)
Gets theDataSerializable
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 theDataBuilder
s to ensure theDataSerializable
requested can be returned.- Type Parameters:
T
- The type ofDataSerializable
object- Parameters:
path
- The path of the value to getclazz
- The class of theDataSerializable
- Returns:
- The deserialized object, if available
-
getSerializableList
<T extends DataSerializable> Optional<List<T>> getSerializableList(DataQuery path, Class<T> clazz)
Gets theList
ofDataSerializable
by path, if available.If a
List
exists, but the contents of the list are not consideredDataSerializable
or are not of the proper type ofDataSerializable
, an absent is returned.It is important that the
DataManager
provided is the same one that has registered many of theDataBuilder
s to ensure theDataSerializable
requested can be returned.- Type Parameters:
T
- The type ofDataSerializable
object- Parameters:
path
- The path of the list value to getclazz
- The class of theDataSerializable
- Returns:
- The deserialized objects in a list, if available
-
getObject
<T> Optional<T> getObject(DataQuery path, Class<T> objectClass)
Gets theObject
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 theDataTranslator
s to ensure theDataSerializable
requested can be returned.
-
getObjectList
<T> Optional<List<T>> getObjectList(DataQuery path, Class<T> objectClass)
Gets theList
ofDataSerializable
by path, if available.If a
List
exists, but the contents of the list are not consideredDataTranslator
"able" or are not of the proper type ofDataTranslator
, an absent is returned.It is important that the
DataManager
provided is the same one that has registered many of theDataTranslator
s to ensure theObject
requested can be returned.
-
getRegistryValue
default <T> Optional<T> getRegistryValue(DataQuery path, RegistryType<T> registryType)
Gets thevalue
by path, if available, from the global registry.- Type Parameters:
T
- The type of dummy- Parameters:
path
- The path of the value to getregistryType
- The class of the dummy type- Returns:
- The dummy type, if available
-
getRegistryValueList
default <T> Optional<List<T>> getRegistryValueList(DataQuery path, RegistryType<T> registryType)
- Type Parameters:
T
- The type of dummy type- Parameters:
path
- The path of the list value to getregistryType
- The type of registry to search- Returns:
- The list of dummy types, if available
-
getRegistryValue
<T> Optional<T> getRegistryValue(DataQuery path, RegistryType<T> registryType, RegistryHolder holder)
Gets thevalue
by path, if available.- Type Parameters:
T
- The type of dummy- Parameters:
path
- The path of the value to getregistryType
- The class of the dummy typeholder
- The holder to get the registry from- Returns:
- The dummy type, if available
-
getRegistryValueList
<T> Optional<List<T>> getRegistryValueList(DataQuery path, RegistryType<T> registryType, RegistryHolder holder)
- Type Parameters:
T
- The type of dummy type- Parameters:
path
- The path of the list value to getregistryType
- The type of registry to searchholder
- the holder to get the registry from- Returns:
- The list of dummy types, if available
-
getDataKey
<E,V extends Value<E>> Optional<Key<V>> getDataKey(DataQuery path)
Gets thekey
by path, if available.- Type Parameters:
E
- The element typeV
- The value type- Parameters:
path
- The path of the value to get- Returns:
- The key, if available
-
getDataKeyList
Optional<List<Key<? extends Value<?>>>> getDataKeyList(DataQuery path)
- Parameters:
path
- The path of the value to get- Returns:
- The list of keys, if available
-
copy
DataContainer copy()
Copies thisDataView
and all of it's contents into a newDataContainer
.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.- Returns:
- The newly constructed data view
-
copy
DataContainer copy(DataView.SafetyMode safety)
Copies thisDataView
and all of it's contents into a newDataContainer
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.- Parameters:
safety
- The safety mode of the copy- Returns:
- The newly constructed data view
-
isEmpty
boolean isEmpty()
Gets if this view contains no data.- Returns:
- True if no data
-
safetyMode
DataView.SafetyMode safetyMode()
Gets theDataView.SafetyMode
of this data view.- Returns:
- The safety mode
-
-