Fork me on GitHub

Node

ConfigurationNodes are the basic object of Configurate. A node represents any singe point in a configuration tree, and can be used to navigate around the tree to extract values. This page aims to cover the most common points about nodes, but the javadocs present the most complete method-by-method documentation.

Creating

In most cases nodes are constructed by ConfigurationLoaders, either in the process of loading a configuration, or by calling the ConfigurationLoader#createEmptyNode(ConfigurationOptions) method. These methods are guaranteed to return the most correct node implementation supported by a specific loader.

Options: The ConfigurationOptions object presents a set of options that control the functionality of a configuration node tree. Passing null for options is not supported. Instead, use ConfigurationOptions.defaults() to get a default options object.

Basic

Interface: ConfigurationNode

Construct: SimpleConfigurationNode.root()

Commented

Interface: CommentedConfigurationNode

Construct: SimpleCommentedConfigurationNode.root()

Navigating

Where am I?

getKey(): Return the key of the current node

getPath(): Return the full path of the current node. This one is kinda expensive because it has to create the array from parents

getParent(): Gets the current parent. If the parent is not attached, this may not be the final parent once this node becomes attached

Let’s go

getNode(Object… path): Get a node at the given path. Each element in the path array is a single level. This method will create a new unattached node if none are present, meaning that it never returns null

What do you value?

getValue() and getValue(Object default): Returns the raw value for the node. If the node is a compound value like a list or a map, this method will unwrap the child nodes (recursively) to give a List or Map return value.

There exist methods to convert this object to values of different types: getString, Int, Float, etc. The getList(Function<Object,T> converter) method is a bit more interesting. It takes a function that is executed for each element in the list to get its final value.

setValue(Object value): Sets the value, wrapping compound values as necessary. Configurate itself does not do any filtering on value types – that’s up to the loader to do.