Class AbstractValueConfigNode

java.lang.Object
tech.guilhermekaua.spigotboot.config.node.AbstractValueConfigNode
All Implemented Interfaces:
ConfigNode
Direct Known Subclasses:
SnapshotConfigNode, YamlConfigNode

public abstract class AbstractValueConfigNode extends Object implements ConfigNode
Shared immutable/read-only behavior for value-backed ConfigNode implementations.

Subclasses provide storage details and child-node creation strategy.

  • Constructor Details

    • AbstractValueConfigNode

      public AbstractValueConfigNode()
  • Method Details

    • currentValue

      @Nullable protected abstract @Nullable Object currentValue()
    • currentPath

      @NotNull protected abstract @NotNull PropertyPath currentPath()
    • currentVirtual

      protected abstract boolean currentVirtual()
    • createChildNode

      @NotNull protected abstract @NotNull ConfigNode createChildNode(@Nullable @Nullable Object value, @NotNull @NotNull PropertyPath path, boolean virtual)
    • raw

      @Nullable public @Nullable Object raw()
      Description copied from interface: ConfigNode
      Gets the raw underlying value.
      Specified by:
      raw in interface ConfigNode
      Returns:
      the raw value, or null if the node is empty
    • get

      @Nullable public <T> T get(@NotNull @NotNull Class<T> type)
      Description copied from interface: ConfigNode
      Gets the value converted to the specified type.
      Specified by:
      get in interface ConfigNode
      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 public <T> T get(@NotNull @NotNull Class<T> type, @NotNull T defaultValue)
      Description copied from interface: ConfigNode
      Gets the value converted to the specified type, with a default fallback.
      Specified by:
      get in interface ConfigNode
      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 public @NotNull ConfigNode node(@NotNull @NotNull Object... pathSegments)
      Description copied from interface: ConfigNode
      Navigates to a child node by path segments.

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

      Specified by:
      node in interface ConfigNode
      Parameters:
      pathSegments - the path segments (strings for map keys, integers for list indices)
      Returns:
      the child node, never null
    • node

      @NotNull public @NotNull ConfigNode node(@NotNull @NotNull PropertyPath path)
      Description copied from interface: ConfigNode
      Navigates to a child node by a property path.

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

      Specified by:
      node in interface ConfigNode
      Parameters:
      path - the PropertyPath to navigate to
      Returns:
      the child node, never null
    • hasChild

      public boolean hasChild(@NotNull @NotNull Object... path)
      Description copied from interface: ConfigNode
      Checks if this node has a child at the given path.
      Specified by:
      hasChild in interface ConfigNode
      Parameters:
      path - the path segments
      Returns:
      true if the child exists and is not virtual
    • childrenMap

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

      @NotNull public @NotNull List<? extends ConfigNode> childrenList()
      Description copied from interface: ConfigNode
      Gets all children as a list (for list nodes).
      Specified by:
      childrenList in interface ConfigNode
      Returns:
      the children list, or empty list if not a list node
    • isMap

      public boolean isMap()
      Description copied from interface: ConfigNode
      Checks if this node is a map (object) node.
      Specified by:
      isMap in interface ConfigNode
      Returns:
      true if this node contains key-value pairs
    • isList

      public boolean isList()
      Description copied from interface: ConfigNode
      Checks if this node is a list (array) node.
      Specified by:
      isList in interface ConfigNode
      Returns:
      true if this node contains a list of values
    • isScalar

      public boolean isScalar()
      Description copied from interface: ConfigNode
      Checks if this node is a scalar (primitive/string) value.
      Specified by:
      isScalar in interface ConfigNode
      Returns:
      true if this node contains a scalar value
    • isNull

      public boolean isNull()
      Description copied from interface: ConfigNode
      Checks if this node's value is null.
      Specified by:
      isNull in interface ConfigNode
      Returns:
      true if the value is null
    • isVirtual

      public boolean isVirtual()
      Description copied from interface: ConfigNode
      Checks if this node is virtual (doesn't exist in the source).

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

      Specified by:
      isVirtual in interface ConfigNode
      Returns:
      true if this node is virtual
    • path

      @NotNull public @NotNull PropertyPath path()
      Description copied from interface: ConfigNode
      Gets the path to this node from root.
      Specified by:
      path in interface ConfigNode
      Returns:
      the path to this node