Class DataTree.Immut

java.lang.Object
space.arim.dazzleconf.backend.DataTree
space.arim.dazzleconf.backend.DataTree.Immut
Enclosing class:
DataTree

public static final class DataTree.Immut extends DataTree
A data tree which is immutable.

This type guarantees that all of its entries are immutable (deep immutability). That is, DataTrees and DataLists contained within this tree's entries will always be immutable.

  • Constructor Details

    • Immut

      public Immut()
      Creates an empty data tree
  • Method Details

    • get

      public @Nullable DataEntry get(@NonNull Object key)
      Description copied from class: DataTree
      Gets the entry at the specified key, or null if unset.

      If accessing keys based on method names, it is strongly recommended to use the KeyMapper to map method names to keys. The key mapper is available during both deserialization and serialization.

      Specified by:
      get in class DataTree
      Parameters:
      key - the key
      Returns:
      the entry
    • forEach

      public void forEach(BiConsumer<? super @NonNull Object,? super @NonNull DataEntry> action)
      Description copied from class: DataTree
      Runs an action for each key/value pair.

      Iteration maintains the order with which this data tree was created.

      Specified by:
      forEach in class DataTree
      Parameters:
      action - the action
    • intoImmut

      public @NonNull DataTree.Immut intoImmut()
      Description copied from class: DataTree
      Gets this data tree as an immutable one.

      The data contained within this DataTree is moved to an immutable instance. The old instance may still be used, but the implementation of this method may be optimized for the case that it is not.

      If this instance is already DataTree.Immut, then it may be returned without changes.

      Specified by:
      intoImmut in class DataTree
      Returns:
      an immutable data tree
    • intoMut

      public @NonNull DataTree.Mut intoMut()
      Description copied from class: DataTree
      Gets this data tree as a mutable one.

      If not mutable, the data is copied to a new tree, which will be made deeply mutable. That is, this function will also be called on any DataTrees encountered in this tree's entries, and DataList.intoMut() on any data lists likewise.

      If this instance is already DataTree.Mut, then it may be returned without changes.

      Specified by:
      intoMut in class DataTree
      Returns:
      this tree if mutable, or a mutable copy if needed