Interface DataView
-
- All Known Subinterfaces:
DataContainer
public interface DataViewRepresents an object of data represented by a map.DataViews always exist within a
DataContainerand can be used for serialization.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classDataView.SafetyModeThe safety mode of the container.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description DataContainercontainer()Gets the parent container of this DataView.booleancontains(DataQuery path)Returns whether thisDataViewcontains the given path.booleancontains(DataQuery path, DataQuery... paths)DataContainercopy()Copies thisDataViewand all of it's contents into a newDataContainer.DataContainercopy(DataView.SafetyMode safety)Copies thisDataViewand all of it's contents into a newDataContainerwith the given safety mode.DataViewcreateView(DataQuery path)Creates a newDataViewat the desired path.DataViewcreateView(DataQuery path, java.util.Map<?,?> map)Creates a newDataViewwith the given data at the desired path.DataQuerycurrentPath()Gets the current path of thisDataViewfrom its rootDataContainer.java.util.Optional<java.lang.Object>get(DataQuery path)Gets an object from the desired path.java.util.Optional<java.lang.Boolean>getBoolean(DataQuery path)Gets theBooleanby path, if available.java.util.Optional<java.util.List<java.lang.Boolean>>getBooleanList(DataQuery path)Gets theListofBooleanby path, if available.java.util.Optional<java.lang.Byte>getByte(DataQuery path)Gets theByteby path, if available.java.util.Optional<java.util.List<java.lang.Byte>>getByteList(DataQuery path)Gets theListofByteby path, if available.java.util.Optional<java.util.List<java.lang.Character>>getCharacterList(DataQuery path)Gets theListofCharacterby path, if available.<E,V extends Value<E>>
java.util.Optional<Key<V>>getDataKey(DataQuery path)Gets thekeyby path, if available.java.util.Optional<java.util.List<Key<? extends Value<?>>>>getDataKeyList(DataQuery path)Gets theListofvaluesby path, if available.java.util.Optional<java.lang.Double>getDouble(DataQuery path)Gets theDoubleby path, if available.java.util.Optional<java.util.List<java.lang.Double>>getDoubleList(DataQuery path)Gets theListofDoubleby path, if available.java.util.Optional<java.lang.Float>getFloat(DataQuery path)Gets theFloatby path, if available.java.util.Optional<java.util.List<java.lang.Float>>getFloatList(DataQuery path)Gets theListofFloatby path, if available.java.util.Optional<java.lang.Integer>getInt(DataQuery path)Gets theIntegerby path, if available.java.util.Optional<java.util.List<java.lang.Integer>>getIntegerList(DataQuery path)Gets theListofIntegerby path, if available.java.util.Optional<java.util.List<?>>getList(DataQuery path)Gets theListof something by path, if available.java.util.Optional<java.lang.Long>getLong(DataQuery path)Gets theLongby path, if available.java.util.Optional<java.util.List<java.lang.Long>>getLongList(DataQuery path)Gets theListofLongby path, if available.java.util.Optional<? extends java.util.Map<?,?>>getMap(DataQuery path)Gets the underlyingMapby path, if available.java.util.Optional<java.util.List<java.util.Map<?,?>>>getMapList(DataQuery path)Gets theListofMapby path, if available.<T> java.util.Optional<T>getObject(DataQuery path, java.lang.Class<T> objectClass)Gets theObjectobject by path, if available.<T> java.util.Optional<java.util.List<T>>getObjectList(DataQuery path, java.lang.Class<T> objectClass)Gets theListofDataSerializableby path, if available.default <T> java.util.Optional<T>getRegistryValue(DataQuery path, RegistryType<T> registryType)Gets thevalueby path, if available, from the global registry.<T> java.util.Optional<T>getRegistryValue(DataQuery path, RegistryType<T> registryType, RegistryHolder holder)Gets thevalueby path, if available.default <T> java.util.Optional<java.util.List<T>>getRegistryValueList(DataQuery path, RegistryType<T> registryType)Gets theListofvaluesby path, if available, from the global registry.<T> java.util.Optional<java.util.List<T>>getRegistryValueList(DataQuery path, RegistryType<T> registryType, RegistryHolder holder)Gets theListofvaluesby path, if available.default java.util.Optional<ResourceKey>getResourceKey(DataQuery path)Gets thekeyby path, if available.default java.util.Optional<java.util.List<ResourceKey>>getResourceKeyList(DataQuery path)Gets theListofkeysby path, if available.<T extends DataSerializable>
java.util.Optional<T>getSerializable(DataQuery path, java.lang.Class<T> clazz)Gets theDataSerializableobject by path, if available.<T extends DataSerializable>
java.util.Optional<java.util.List<T>>getSerializableList(DataQuery path, java.lang.Class<T> clazz)Gets theListofDataSerializableby path, if available.java.util.Optional<java.lang.Short>getShort(DataQuery path)Gets theShortby path, if available.java.util.Optional<java.util.List<java.lang.Short>>getShortList(DataQuery path)Gets theListofShortby path, if available.java.util.Optional<java.lang.String>getString(DataQuery path)Gets theStringby path, if available.java.util.Optional<java.util.List<java.lang.String>>getStringList(DataQuery path)Gets theListofStringby path, if available.java.util.Optional<DataView>getView(DataQuery path)Gets theDataViewby path, if available.java.util.Optional<java.util.List<DataView>>getViewList(DataQuery path)Gets theListofDataViewby path, if available.booleanisEmpty()Gets if this view contains no data.java.util.Set<DataQuery>keys(boolean deep)Gets a collection containing all keys in thisDataView.java.lang.Stringname()Gets the name of this individualDataViewin the path.java.util.Optional<DataView>parent()Gets the parentDataViewof this view.DataViewremove(DataQuery path)Removes the data associated to the given path relative to thisDataView's path.DataView.SafetyModesafetyMode()Gets theDataView.SafetyModeof this data view.DataViewset(DataQuery path, java.lang.Object value)Sets the given Object value according to the given path relative to thisDataView's path.java.util.Map<DataQuery,java.lang.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 thisDataViewfrom its rootDataContainer.For any
DataContaineritself, this will return an empty string as it is the root of the path.The full path will always include this
DataViews name at the end of the path.- Returns:
- The path of this view originating from the root
-
name
java.lang.String name()
Gets the name of this individualDataViewin the path.This will always be the final substring of the full path from
currentPath().- Returns:
- The name of this DataView
-
parent
java.util.Optional<DataView> parent()
Gets the parentDataViewof 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
java.util.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
DataViews (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
java.util.Map<DataQuery,java.lang.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
DataViews (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 thisDataViewcontains 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
java.util.Optional<java.lang.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, java.lang.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 newDataViewat 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, java.util.Map<?,?> map)
Creates a newDataViewwith 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
java.util.Optional<DataView> getView(DataQuery path)
Gets theDataViewby path, if available.If a
DataViewdoes 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
java.util.Optional<? extends java.util.Map<?,?>> getMap(DataQuery path)
Gets the underlyingMapby path, if available.If a
Mapdoes 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
java.util.Optional<java.lang.Boolean> getBoolean(DataQuery path)
Gets theBooleanby path, if available.If a
Booleandoes 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
java.util.Optional<java.lang.Short> getShort(DataQuery path)
Gets theShortby path, if available.If a
Shortdoes 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
java.util.Optional<java.lang.Byte> getByte(DataQuery path)
Gets theByteby path, if available.If a
Bytedoes 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
java.util.Optional<java.lang.Integer> getInt(DataQuery path)
Gets theIntegerby path, if available.If a
Integerdoes 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
java.util.Optional<java.lang.Long> getLong(DataQuery path)
Gets theLongby path, if available.If a
Longdoes 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
java.util.Optional<java.lang.Float> getFloat(DataQuery path)
Gets theFloatby path, if available.If a
Floatdoes 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
java.util.Optional<java.lang.Double> getDouble(DataQuery path)
Gets theDoubleby path, if available.If a
Doubledoes 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
java.util.Optional<java.lang.String> getString(DataQuery path)
Gets theStringby path, if available.If a
Stringdoes 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 java.util.Optional<ResourceKey> getResourceKey(DataQuery path)
Gets thekeyby path, if available.- Parameters:
path- The path of the value to get- Returns:
- The key, if available
-
getResourceKeyList
default java.util.Optional<java.util.List<ResourceKey>> getResourceKeyList(DataQuery path)
Gets theListofkeysby path, if available.- Parameters:
path- The path of the value to get- Returns:
- The list of keys, if available
-
getList
java.util.Optional<java.util.List<?>> getList(DataQuery path)
Gets theListof something by path, if available.If a
Listof something does not exist, or the data residing at the path is not an instance of aListof something, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list, if available
-
getStringList
java.util.Optional<java.util.List<java.lang.String>> getStringList(DataQuery path)
Gets theListofStringby path, if available.If a
ListofStringdoes not exist, or the data residing at the path is not an instance of aListofString, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list of strings, if available
-
getCharacterList
java.util.Optional<java.util.List<java.lang.Character>> getCharacterList(DataQuery path)
Gets theListofCharacterby path, if available.If a
ListofCharacterdoes not exist, or the data residing at the path is not an instance of aListofCharacter, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list of characters, if available
-
getBooleanList
java.util.Optional<java.util.List<java.lang.Boolean>> getBooleanList(DataQuery path)
Gets theListofBooleanby path, if available.If a
ListofBooleandoes not exist, or the data residing at the path is not an instance of aListofBoolean, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list of booleans, if available
-
getByteList
java.util.Optional<java.util.List<java.lang.Byte>> getByteList(DataQuery path)
Gets theListofByteby path, if available.If a
ListofBytedoes not exist, or the data residing at the path is not an instance of aListofByte, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list of bytes, if available
-
getShortList
java.util.Optional<java.util.List<java.lang.Short>> getShortList(DataQuery path)
Gets theListofShortby path, if available.If a
ListofShortdoes not exist, or the data residing at the path is not an instance of aListofShort, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list of shorts, if available
-
getIntegerList
java.util.Optional<java.util.List<java.lang.Integer>> getIntegerList(DataQuery path)
Gets theListofIntegerby path, if available.If a
ListofIntegerdoes not exist, or the data residing at the path is not an instance of aListofInteger, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list of integers, if available
-
getLongList
java.util.Optional<java.util.List<java.lang.Long>> getLongList(DataQuery path)
Gets theListofLongby path, if available.If a
ListofLongdoes not exist, or the data residing at the path is not an instance of aListofLong, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list of longs, if available
-
getFloatList
java.util.Optional<java.util.List<java.lang.Float>> getFloatList(DataQuery path)
Gets theListofFloatby path, if available.If a
ListofFloatdoes not exist, or the data residing at the path is not an instance of aListofFloat, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list of floats, if available
-
getDoubleList
java.util.Optional<java.util.List<java.lang.Double>> getDoubleList(DataQuery path)
Gets theListofDoubleby path, if available.If a
ListofDoubledoes not exist, or the data residing at the path is not an instance of aListofDouble, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list of doubles, if available
-
getMapList
java.util.Optional<java.util.List<java.util.Map<?,?>>> getMapList(DataQuery path)
Gets theListofMapby path, if available.If a
ListofMapdoes not exist, or the data residing at the path is not an instance of aListofMap, an absent is returned.- Parameters:
path- The path of the value to get- Returns:
- The list of maps, if available
-
getViewList
java.util.Optional<java.util.List<DataView>> getViewList(DataQuery path)
Gets theListofDataViewby path, if available.If a
ListofDataViewdoes not exist, or the data residing at the path is not an instance of aListofDataView, 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> java.util.Optional<T> getSerializable(DataQuery path, java.lang.Class<T> clazz)
Gets theDataSerializableobject by path, if available.If a
DataSerializableexists, 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
DataManagerprovided is the same one that has registered many of theDataBuilders to ensure theDataSerializablerequested can be returned.- Type Parameters:
T- The type ofDataSerializableobject- Parameters:
path- The path of the value to getclazz- The class of theDataSerializable- Returns:
- The deserialized object, if available
-
getSerializableList
<T extends DataSerializable> java.util.Optional<java.util.List<T>> getSerializableList(DataQuery path, java.lang.Class<T> clazz)
Gets theListofDataSerializableby path, if available.If a
Listexists, but the contents of the list are not consideredDataSerializableor are not of the proper type ofDataSerializable, an absent is returned.It is important that the
DataManagerprovided is the same one that has registered many of theDataBuilders to ensure theDataSerializablerequested can be returned.- Type Parameters:
T- The type ofDataSerializableobject- 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> java.util.Optional<T> getObject(DataQuery path, java.lang.Class<T> objectClass)
Gets theObjectobject by path, if available.If a
Objectexists, 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
DataManagerprovided is the same one that has registered many of theDataTranslators to ensure theDataSerializablerequested can be returned.- Type Parameters:
T- The type ofObjectobject- Parameters:
path- The path of the value to getobjectClass- The class of theObject- Returns:
- The deserialized object, if available
-
getObjectList
<T> java.util.Optional<java.util.List<T>> getObjectList(DataQuery path, java.lang.Class<T> objectClass)
Gets theListofDataSerializableby path, if available.If a
Listexists, 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
DataManagerprovided is the same one that has registered many of theDataTranslators to ensure theObjectrequested can be returned.- Type Parameters:
T- The type ofObjectobject- Parameters:
path- The path of the value to getobjectClass- The class of theObject- Returns:
- The deserialized objects in a list, if available
-
getRegistryValue
default <T> java.util.Optional<T> getRegistryValue(DataQuery path, RegistryType<T> registryType)
Gets thevalueby 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> java.util.Optional<java.util.List<T>> getRegistryValueList(DataQuery path, RegistryType<T> registryType)
Gets theListofvaluesby path, if available, from the global registry.- 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> java.util.Optional<T> getRegistryValue(DataQuery path, RegistryType<T> registryType, RegistryHolder holder)
Gets thevalueby 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> java.util.Optional<java.util.List<T>> getRegistryValueList(DataQuery path, RegistryType<T> registryType, RegistryHolder holder)
Gets theListofvaluesby path, if available.- 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>> java.util.Optional<Key<V>> getDataKey(DataQuery path)
Gets thekeyby 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
java.util.Optional<java.util.List<Key<? extends Value<?>>>> getDataKeyList(DataQuery path)
Gets theListofvaluesby path, if available.- Parameters:
path- The path of the value to get- Returns:
- The list of keys, if available
-
copy
DataContainer copy()
Copies thisDataViewand all of it's contents into a newDataContainer.Note that the copy will not have the same path as this
DataViewsince it will be constructed with the top level path being itself.- Returns:
- The newly constructed data view
-
copy
DataContainer copy(DataView.SafetyMode safety)
Copies thisDataViewand all of it's contents into a newDataContainerwith the given safety mode.Note that the copy will not have the same path as this
DataViewsince 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.SafetyModeof this data view.- Returns:
- The safety mode
-
-