public class MemoryDataView extends Object implements DataView
DataView
being used in memory.Modifier | Constructor and Description |
---|---|
protected |
MemoryDataView() |
protected |
MemoryDataView(DataView parent,
DataQuery path) |
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. |
boolean |
equals(Object obj) |
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)
|
int |
hashCode() |
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)
|
public DataContainer getContainer()
DataView
Every DataView will always have a DataContainer
.
For any DataContainer
, this will return itself.
getContainer
in interface DataView
public DataQuery getCurrentPath()
DataView
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.
getCurrentPath
in interface DataView
public String getName()
DataView
DataView
in the path.
This will always be the final substring of the full path
from DataView.getCurrentPath()
.
public Optional<DataView> getParent()
DataView
DataView
of this view. The parent directly
contains this view according to the DataView.getCurrentPath()
.
For any DataContainer
, this will return an absent parent.
public Set<DataQuery> getKeys(boolean deep)
DataView
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.
public Map<DataQuery,Object> getValues(boolean deep)
DataView
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.
public boolean contains(DataQuery path)
DataView
DataView
contains the given path.public Optional<Object> get(DataQuery path)
DataView
public DataView set(DataQuery path, Object value)
DataView
DataView
's path.public <E> DataView set(Key<? extends BaseValue<E>> key, E value)
DataView
public DataView createView(DataQuery path)
DataView
DataView
at the desired path.
If any data existed at the given path, that data will be
overwritten with the newly constructed DataView
.
createView
in interface DataView
path
- The path of the new viewpublic DataView createView(DataQuery path, Map<?,?> map)
DataView
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
.
createView
in interface DataView
path
- The path of the new viewmap
- The data to store in the new viewpublic Optional<DataView> getView(DataQuery path)
DataView
public Optional<? extends Map<?,?>> getMap(DataQuery path)
DataView
public Optional<Boolean> getBoolean(DataQuery path)
DataView
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.
getBoolean
in interface DataView
path
- The path of the value to getpublic Optional<Double> getDouble(DataQuery path)
DataView
public Optional<String> getString(DataQuery path)
DataView
public Optional<List<?>> getList(DataQuery path)
DataView
public Optional<List<String>> getStringList(DataQuery path)
DataView
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.
getStringList
in interface DataView
path
- The path of the value to getpublic Optional<List<Character>> getCharacterList(DataQuery path)
DataView
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.
getCharacterList
in interface DataView
path
- The path of the value to getpublic Optional<List<Boolean>> getBooleanList(DataQuery path)
DataView
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.
getBooleanList
in interface DataView
path
- The path of the value to getpublic Optional<List<Byte>> getByteList(DataQuery path)
DataView
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.
getByteList
in interface DataView
path
- The path of the value to getpublic Optional<List<Short>> getShortList(DataQuery path)
DataView
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.
getShortList
in interface DataView
path
- The path of the value to getpublic Optional<List<Integer>> getIntegerList(DataQuery path)
DataView
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.
getIntegerList
in interface DataView
path
- The path of the value to getpublic Optional<List<Long>> getLongList(DataQuery path)
DataView
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.
getLongList
in interface DataView
path
- The path of the value to getpublic Optional<List<Float>> getFloatList(DataQuery path)
DataView
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.
getFloatList
in interface DataView
path
- The path of the value to getpublic Optional<List<Double>> getDoubleList(DataQuery path)
DataView
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.
getDoubleList
in interface DataView
path
- The path of the value to getpublic Optional<List<Map<?,?>>> getMapList(DataQuery path)
DataView
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.
getMapList
in interface DataView
path
- The path of the value to getpublic Optional<List<DataView>> getViewList(DataQuery path)
DataView
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.
getViewList
in interface DataView
path
- The path of the value to getpublic <T extends DataSerializable> Optional<T> getSerializable(DataQuery path, Class<T> clazz, SerializationService service)
DataView
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.
getSerializable
in interface DataView
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 builderspublic <T extends DataSerializable> Optional<List<T>> getSerializableList(DataQuery path, Class<T> clazz, SerializationService service)
DataView
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.
getSerializableList
in interface DataView
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 builderspublic DataContainer copy()
DataView
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.