Interface ConfigNode

All Known Subinterfaces:
Config
All Known Implementing Classes:
BukkitConfig, BukkitConfig.BukkitConfigNode, BungeeConfig, BungeeConfig.BungeeConfigNode, ConfigurateConfig, ConfigurateConfig.ConfigurateConfigNode, GsonConfig, GsonConfig.GsonConfigNode

public interface ConfigNode
A node in the configuration tree. Provides access to values, child nodes, and comments.
  • Method Details

    • getPath

      String[] getPath()
      Get the path relative to the origin node. When obtained from Config.node(), returns the full path from root. When obtained from ConfigNode.node() or getChildren(), returns the relative path.
      Returns:
      the path segments
    • getParent

      ConfigNode getParent()
      Get the parent node (the origin). When obtained from Config.node(), returns the Config (root node). When obtained from ConfigNode.node() or getChildren(), returns that ConfigNode.
      Returns:
      the parent node
    • getConfig

      Config getConfig()
      Get the root Config that owns this node
      Returns:
      the owning Config
    • get

      Object get()
      Get the value at this node
      Returns:
      the value, or null if not present
    • get

      default Object get(Object def)
      Get the value at this node, returning a default if absent
      Parameters:
      def - the default value
      Returns:
      the value, or the default if not present
    • get

      default <T> T get(Class<T> type)
      Get a typed value at this node
      Type Parameters:
      T - the type
      Parameters:
      type - the type class
      Returns:
      the typed value, or null if not present or not assignable
    • get

      default <T> T get(Class<T> type, T def)
      Get a typed value at this node with a default
      Type Parameters:
      T - the type
      Parameters:
      type - the type class
      def - the default value
      Returns:
      the typed value, or the default if not present or not assignable
    • set

      void set(Object value)
      Set the value at this node
      Parameters:
      value - the value to set
    • setIfAbsent

      default void setIfAbsent(Object value)
      Set the value at this node if it does not already exist
      Parameters:
      value - the value to set
    • node

      ConfigNode node(String... path)
      Navigate to a child node. Should only be called if hasChild() returns true.
      Parameters:
      path - the path segments (relative to this node)
      Returns:
      the child node
    • exists

      default boolean exists()
      Check if this node exists in the configuration
      Returns:
      true if this node has a value
    • remove

      void remove()
      Remove this node from the configuration
    • hasChild

      boolean hasChild()
      Check if this node has children
      Returns:
      true if this node has child nodes
    • getChildren

      Map<String,ConfigNode> getChildren()
      Get the child nodes of this node. Should only be called if hasChild() returns true.
      Returns:
      map of child key to child node
    • getNormalized

      default Object getNormalized()
      Get the normalized value at this node (plain Java types). Recursively normalizes Maps and Collections.
      Returns:
      the normalized value, or null if not present
    • normalizeObject

      default Object normalizeObject(Object object)
      Normalize an object and its elements if it is a Map or Collection. Uses the owning Config's normalize/isNormalizable methods.
      Parameters:
      object - the object
      Returns:
      the normalized object
    • getComment

      default List<String> getComment()
      Get the block comment for this node
      Returns:
      the comment lines, or empty list if none
    • setComment

      default void setComment(List<String> value)
      Set the block comment for this node
      Parameters:
      value - the comment lines, or null to remove
    • getComment

      default List<String> getComment(CommentType type)
      Get the comment for this node
      Parameters:
      type - the comment type
      Returns:
      the comment lines, or empty list if none
    • setComment

      default void setComment(CommentType type, List<String> value)
      Set the comment for this node
      Parameters:
      type - the comment type
      value - the comment lines, or null to remove