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.

  • Method Details

    • 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 this 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 DataViews 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 individual DataView 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 parent DataView of this view. The parent directly contains this view according to the currentPath().

      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 this DataView.

      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

      Map<DataQuery,​Object> values(boolean deep)
      Gets a Map containing all keys and their values for this DataView.

      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 this DataView 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)
      Returns whether this DataView contains an entry for all provided DataQuery objects.
      Parameters:
      path - The path relative to this data view
      paths - 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 this DataView's path.
      Parameters:
      path - The path of the object to set
      value - 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 this DataView'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 new DataView 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 new 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.

      Parameters:
      path - The path of the new view
      map - The data to store in the new view
      Returns:
      The new view
    • getView

      Optional<DataView> getView(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The data view, if available
    • getMap

      Optional<? extends Map<?,​?>> getMap(DataQuery path)
      Gets the underlying 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The map, if available
    • getBoolean

      Optional<Boolean> getBoolean(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The boolean, if available
    • getShort

      Optional<Short> getShort(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The boolean, if available
    • getByte

      Optional<Byte> getByte(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The boolean, if available
    • getInt

      Optional<Integer> getInt(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The integer, if available
    • getLong

      Optional<Long> getLong(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The long, if available
    • getFloat

      Optional<Float> getFloat(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The boolean, if available
    • getDouble

      Optional<Double> getDouble(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The double, if available
    • getString

      Optional<String> getString(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The string, if available
    • getResourceKey

      default Optional<ResourceKey> getResourceKey(DataQuery path)
      Gets the key 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)
      Gets the List of keys by path, if available.
      Parameters:
      path - The path of the value to get
      Returns:
      The list of keys, if available
    • getList

      Optional<List<?>> getList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list, if available
    • getStringList

      Optional<List<String>> getStringList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list of strings, if available
    • getCharacterList

      Optional<List<Character>> getCharacterList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list of characters, if available
    • getBooleanList

      Optional<List<Boolean>> getBooleanList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list of booleans, if available
    • getByteList

      Optional<List<Byte>> getByteList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list of bytes, if available
    • getShortList

      Optional<List<Short>> getShortList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list of shorts, if available
    • getIntegerList

      Optional<List<Integer>> getIntegerList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list of integers, if available
    • getLongList

      Optional<List<Long>> getLongList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list of longs, if available
    • getFloatList

      Optional<List<Float>> getFloatList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list of floats, if available
    • getDoubleList

      Optional<List<Double>> getDoubleList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list of doubles, if available
    • getMapList

      Optional<List<Map<?,​?>>> getMapList(DataQuery path)
      Gets the 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.

      Parameters:
      path - The path of the value to get
      Returns:
      The list of maps, if available
    • getViewList

      Optional<List<DataView>> getViewList(DataQuery path)
      Gets the 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.

      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 the 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 DataBuilders to ensure the DataSerializable requested can be returned.

      Type Parameters:
      T - The type of DataSerializable object
      Parameters:
      path - The path of the value to get
      clazz - The class of the DataSerializable
      Returns:
      The deserialized object, if available
    • getSerializableList

      <T extends DataSerializable> Optional<List<T>> getSerializableList(DataQuery path, Class<T> clazz)
      Gets the 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 DataBuilders to ensure the DataSerializable requested can be returned.

      Type Parameters:
      T - The type of DataSerializable object
      Parameters:
      path - The path of the list value to get
      clazz - The class of the DataSerializable
      Returns:
      The deserialized objects in a list, if available
    • getObject

      <T> Optional<T> getObject(DataQuery path, Class<T> objectClass)
      Gets the 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 DataTranslators to ensure the DataSerializable requested can be returned.

      Type Parameters:
      T - The type of Object object
      Parameters:
      path - The path of the value to get
      objectClass - The class of the Object
      Returns:
      The deserialized object, if available
    • getObjectList

      <T> Optional<List<T>> getObjectList(DataQuery path, Class<T> objectClass)
      Gets the 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 DataTranslators to ensure the Object requested can be returned.

      Type Parameters:
      T - The type of Object object
      Parameters:
      path - The path of the value to get
      objectClass - The class of the Object
      Returns:
      The deserialized objects in a list, if available
    • getRegistryValue

      default <T> Optional<T> getRegistryValue(DataQuery path, RegistryType<T> registryType)
      Gets the value by path, if available, from the global registry.
      Type Parameters:
      T - The type of dummy
      Parameters:
      path - The path of the value to get
      registryType - The class of the dummy type
      Returns:
      The dummy type, if available
    • getRegistryValueList

      default <T> Optional<List<T>> getRegistryValueList(DataQuery path, RegistryType<T> registryType)
      Gets the List of values by path, if available, from the global registry.
      Type Parameters:
      T - The type of dummy type
      Parameters:
      path - The path of the list value to get
      registryType - 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 the value by path, if available.
      Type Parameters:
      T - The type of dummy
      Parameters:
      path - The path of the value to get
      registryType - The class of the dummy type
      holder - 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)
      Gets the List of values by path, if available.
      Type Parameters:
      T - The type of dummy type
      Parameters:
      path - The path of the list value to get
      registryType - The type of registry to search
      holder - 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 the key by path, if available.
      Type Parameters:
      E - The element type
      V - 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)
      Gets the List of values by path, if available.
      Parameters:
      path - The path of the value to get
      Returns:
      The list of keys, if available
    • copy

      Copies this 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.

      Returns:
      The newly constructed data view
    • copy

      Copies this 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.

      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 the DataView.SafetyMode of this data view.
      Returns:
      The safety mode