Interface ConfigNode

All Known Subinterfaces:
MutableConfigNode
All Known Implementing Classes:
AbstractValueConfigNode, SnapshotConfigNode, YamlConfigNode

public interface ConfigNode
Immutable representation of a configuration node.

A ConfigNode wraps a value in the configuration tree and provides type-safe access to its data. Nodes can be scalars, maps, or lists.

  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull List<? extends ConfigNode>
    Gets all children as a list (for list nodes).
    @NotNull Map<String,? extends ConfigNode>
    Gets all children as a map (for map nodes).
    <T> T
    get(@NotNull Class<T> type)
    Gets the value converted to the specified type.
    <T> T
    get(@NotNull Class<T> type, T defaultValue)
    Gets the value converted to the specified type, with a default fallback.
    boolean
    hasChild(@NotNull Object... path)
    Checks if this node has a child at the given path.
    boolean
    Checks if this node is a list (array) node.
    boolean
    Checks if this node is a map (object) node.
    boolean
    Checks if this node's value is null.
    boolean
    Checks if this node is a scalar (primitive/string) value.
    boolean
    Checks if this node is virtual (doesn't exist in the source).
    @NotNull ConfigNode
    node(@NotNull Object... path)
    Navigates to a child node by path segments.
    @NotNull ConfigNode
    node(@NotNull PropertyPath path)
    Navigates to a child node by a property path.
    @NotNull PropertyPath
    Gets the path to this node from root.
    @Nullable Object
    raw()
    Gets the raw underlying value.
  • Method Details

    • raw

      @Nullable @Nullable Object raw()
      Gets the raw underlying value.
      Returns:
      the raw value, or null if the node is empty
    • get

      @Nullable <T> T get(@NotNull @NotNull Class<T> type)
      Gets the value converted to the specified type.
      Type Parameters:
      T - the type parameter
      Parameters:
      type - the target type
      Returns:
      the converted value, or null if conversion fails or value is null
    • get

      @NotNull <T> T get(@NotNull @NotNull Class<T> type, @NotNull T defaultValue)
      Gets the value converted to the specified type, with a default fallback.
      Type Parameters:
      T - the type parameter
      Parameters:
      type - the target type
      defaultValue - the default value if conversion fails or value is null
      Returns:
      the converted value or the default
    • node

      @NotNull @NotNull ConfigNode node(@NotNull @NotNull Object... path)
      Navigates to a child node by path segments.

      If the path doesn't exist, returns a virtual (empty) node.

      Parameters:
      path - the path segments (strings for map keys, integers for list indices)
      Returns:
      the child node, never null
    • node

      @NotNull @NotNull ConfigNode node(@NotNull @NotNull PropertyPath path)
      Navigates to a child node by a property path.

      If the path doesn't exist, returns a virtual (empty) node.

      Parameters:
      path - the PropertyPath to navigate to
      Returns:
      the child node, never null
    • hasChild

      boolean hasChild(@NotNull @NotNull Object... path)
      Checks if this node has a child at the given path.
      Parameters:
      path - the path segments
      Returns:
      true if the child exists and is not virtual
    • childrenMap

      @NotNull @NotNull Map<String,? extends ConfigNode> childrenMap()
      Gets all children as a map (for map nodes).
      Returns:
      the children map, or empty map if not a map node
    • childrenList

      @NotNull @NotNull List<? extends ConfigNode> childrenList()
      Gets all children as a list (for list nodes).
      Returns:
      the children list, or empty list if not a list node
    • isMap

      boolean isMap()
      Checks if this node is a map (object) node.
      Returns:
      true if this node contains key-value pairs
    • isList

      boolean isList()
      Checks if this node is a list (array) node.
      Returns:
      true if this node contains a list of values
    • isScalar

      boolean isScalar()
      Checks if this node is a scalar (primitive/string) value.
      Returns:
      true if this node contains a scalar value
    • isNull

      boolean isNull()
      Checks if this node's value is null.
      Returns:
      true if the value is null
    • isVirtual

      boolean isVirtual()
      Checks if this node is virtual (doesn't exist in the source).

      Virtual nodes are returned when navigating to non-existent paths.

      Returns:
      true if this node is virtual
    • path

      @NotNull @NotNull PropertyPath path()
      Gets the path to this node from root.
      Returns:
      the path to this node