java.lang.Object
org.polyfrost.oneconfig.api.config.v1.Node
org.polyfrost.oneconfig.api.config.v1.Tree
All Implemented Interfaces:
Serializable

public class Tree extends Node implements Serializable
The Tree class represents a tree structure that contains properties and other trees as children. It provides various methods to access, modify, and compare the tree and its elements.
See Also:
  • Field Details

  • Constructor Details

    • Tree

      public Tree(@Nullable @Nullable String id, @Nullable @Nullable Object title, @Nullable @Nullable Object description, @Nullable @Nullable Map<String,Node> items)
  • Method Details

    • beginFailureCollection

      @Internal public static void beginFailureCollection()
    • endFailureCollection

      @Internal public static List<String> endFailureCollection()
    • tree

      @NotNull public static @NotNull Tree tree()
    • tree

      @Contract("_, -> new") @NotNull public static @NotNull Tree tree(@NotNull @NotNull String id)
    • tree

      @Contract("_ -> new") @NotNull public static @NotNull Tree tree(@NotNull @NotNull Tree src)
      Create a new builder from the given tree. This will copy all the data from the tree into the builder.
    • put

      public Tree put(@NotNull @NotNull Node... nodes)
    • put

      public Tree put(Node n)
    • set

      public Tree set(String id, Node n)
    • get

      @Nullable public @Nullable Node get(String id)
    • get

      @Nullable public @Nullable Node get(@NotNull @NotNull String... id)
    • get

      @Nullable public @Nullable Node get(@NotNull @NotNull Iterable<String> id)
    • getChild

      public Tree getChild(@NotNull @NotNull String... id)
    • getChild

      public Tree getChild(@NotNull @NotNull String id)
    • getOrPutChild

      public Tree getOrPutChild(@NotNull @NotNull String id)
    • getProp

      public Property<?> getProp(@NotNull @NotNull String... id)
    • getProp

      public Property<?> getProp(@NotNull @NotNull String id)
    • onAll

      public void onAll(BiConsumer<String,Node> action)
    • onAllProps

      public void onAllProps(BiConsumer<String,Property<?>> action)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • deepEquals

      public boolean deepEquals(@Nullable @Nullable Object obj)
      Check if the tree's contents equals another tree's. This will check the values and children of the tree.
      Specified by:
      deepEquals in class Node
      Parameters:
      obj - the tree to check against
      Returns:
      whether the trees are equal
    • overwrite

      public void overwrite(Tree with, @NotNull @NotNull Function<String,String> keyMapper, boolean preserveMissingOptions, boolean skipOverwritten, @Nullable @Nullable Tree root)
      Overwrite this tree with the supplied tree, using the keyMapper to map between key names from old to new if needed.
      Parameters:
      with - the tree to overwrite with
      keyMapper - the key mapper function to use
    • overwrite

      public void overwrite(@NotNull @NotNull Node with, boolean preserveMissingOptions, boolean skipOverwritten, @Nullable @Nullable Tree root)
      Description copied from class: Node
      Overwrite all data in this node with the data from another node.
      • For a node, all metadata will be copied from the input onto this. any duplicate keys will be overwritten.
      • For a Property, the value, callbacks and display conditions are copied onto this.
      • For a Tree, all children and properties will be overwritten if they are present. this operation is recursive.
      Specified by:
      overwrite in class Node
      Parameters:
      with - the node to overwrite this with
      preserveMissingOptions - if true, any properties that are missing in THIS tree that are present in the input tree, will be added to this tree.
      skipOverwritten - **DEPENDS ON PARAM "ROOT" BEING NOT NULL** - skips being overwritten if a child node has already been marked as overwritten in the root tree.
      root - The root tree used to mark overwritten nodes for skipOverwritten. May be null if skipOverwritten is false.
    • unpack

      public Map<String,Object> unpack()
      Unpack this tree into a map of objects, containing either more Maps or the values of the properties of this tree.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • contentToString

      public String contentToString()
    • clear

      @Internal public void clear()
      Clear this tree of all its members.
      This function is used internally to discard trees to prevent illegal usage of 'dead' trees.
    • evaluatePath

      public static String evaluatePath(Tree root, Node node)
      Figure out what the path from the given root to the given node is.