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 Summary
Modifier and TypeMethodDescriptiondefault booleanexists()Check if this node exists in the configurationget()Get the value at this nodedefault <T> TGet a typed value at this nodedefault <T> TGet a typed value at this node with a defaultdefault ObjectGet the value at this node, returning a default if absentGet the child nodes of this node.Get the block comment for this nodegetComment(CommentType type) Get the comment for this nodeGet the root Config that owns this nodedefault ObjectGet the normalized value at this node (plain Java types).Get the parent node (the origin).String[]getPath()Get the path relative to the origin node.booleanhasChild()Check if this node has childrenNavigate to a child node.default ObjectnormalizeObject(Object object) Normalize an object and its elements if it is a Map or Collection.voidremove()Remove this node from the configurationvoidSet the value at this nodedefault voidsetComment(CommentType type, List<String> value) Set the comment for this nodedefault voidsetComment(List<String> value) Set the block comment for this nodedefault voidsetIfAbsent(Object value) Set the value at this node if it does not already exist
-
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
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
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
Get a typed value at this node with a default- Type Parameters:
T- the type- Parameters:
type- the type classdef- the default value- Returns:
- the typed value, or the default if not present or not assignable
-
set
Set the value at this node- Parameters:
value- the value to set
-
setIfAbsent
Set the value at this node if it does not already exist- Parameters:
value- the value to set
-
node
Navigate to a child node. Should only be called ifhasChild()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 ifhasChild()returns true.- Returns:
- map of child key to child node
-
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
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
Get the block comment for this node- Returns:
- the comment lines, or empty list if none
-
setComment
Set the block comment for this node- Parameters:
value- the comment lines, or null to remove
-
getComment
Get the comment for this node- Parameters:
type- the comment type- Returns:
- the comment lines, or empty list if none
-
setComment
Set the comment for this node- Parameters:
type- the comment typevalue- the comment lines, or null to remove
-