Class ConfigNode

java.lang.Object
com.djrapitops.plan.settings.config.ConfigNode
Direct Known Subclasses:
Config

public class ConfigNode extends Object
Represents a single node in a configuration file

Based on https://github.com/AuroraLS3/Abstract-Plugin-Framework/blob/72e221d3571ef200727713d10d3684c51e9f469d/AbstractPluginFramework/api/src/main/java/com/djrapitops/plugin/config/ConfigNode.java

  • Field Details

  • Constructor Details

  • Method Details

    • updateParent

      protected void updateParent(ConfigNode newParent)
    • getNode

      public Optional<ConfigNode> getNode(String path)
    • contains

      public boolean contains(String path)
    • addNode

      public ConfigNode addNode(String path)
    • removeNode

      public boolean removeNode(String path)
      Remove a node at a certain path.
      Parameters:
      path - Path to the node that is up for removal.
      Returns:
      true if the node was present and is now removed. false if the path did not have a node.
    • remove

      public void remove()
    • addChild

      protected ConfigNode addChild(ConfigNode child)
      Add a new child ConfigNode.
      Parameters:
      child - ConfigNode to add. If from another config tree, the parent is 'cut', which breaks the old tree traversal.
      Returns:
      Return the node given, now part of this tree.
    • removeChild

      protected void removeChild(ConfigNode child)
    • moveChild

      public boolean moveChild(String oldPath, String newPath)
      Moves a node from old path to new path.
      Parameters:
      oldPath - Old path of the node.
      newPath - New path of the node.
      Returns:
      true if the move was successful. false if the new node is not present
    • getKey

      public String getKey(boolean deep)
    • sort

      public void sort()
    • reorder

      public void reorder(List<String> newOrder)
    • save

      public void save() throws IOException
      Find the root node and save.
      Throws:
      IOException - If the save can not be performed.
    • set

      public <T> void set(String path, T value)
    • set

      public <T> void set(T value)
    • getComment

      public List<String> getComment()
    • setComment

      public void setComment(List<String> comment)
    • getStringList

      public List<String> getStringList()
    • getInteger

      public Integer getInteger()
    • getLong

      public Long getLong()
    • getString

      public String getString()
    • getDouble

      public Double getDouble()
    • getBoolean

      public boolean getBoolean()
    • getStringList

      public List<String> getStringList(String path)
    • getStringMap

      public Map<String,String> getStringMap(boolean fullKeys)
      Return values in a Map.
      Parameters:
      fullKeys - Should the key be full keys of the Config node.
      Returns:
      Map with Config key - ConfigNode#getString.
    • getConfigPaths

      public List<String> getConfigPaths()
      Returns:
      List of config keys
    • dfs

      public <T> List<T> dfs(BiConsumer<ConfigNode,List<T>> accessVisitor)
    • getInteger

      public Integer getInteger(String path)
    • getLong

      public Long getLong(String path)
    • getString

      public String getString(String path)
    • getBoolean

      public boolean getBoolean(String path)
    • getDouble

      public Double getDouble(String path)
    • copyMissing

      public void copyMissing(ConfigNode from)
    • copyAll

      public void copyAll(ConfigNode from)
    • copyValue

      public void copyValue(ConfigNode from)
    • getNodeDepth

      protected int getNodeDepth()
    • getParent

      public ConfigNode getParent()
    • isLeafNode

      public boolean isLeafNode()
    • getNodeOrder

      protected List<String> getNodeOrder()
    • getChildren

      public Collection<ConfigNode> getChildren()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object