public class SimpleConfigurationNode extends Object implements ConfigurationNode
NUMBER_DEF
Modifier | Constructor and Description |
---|---|
protected |
SimpleConfigurationNode(Object key,
SimpleConfigurationNode parent,
ConfigurationOptions options) |
Modifier and Type | Method and Description |
---|---|
protected void |
attachChild(SimpleConfigurationNode child) |
protected void |
attachIfNecessary() |
protected void |
clear() |
protected SimpleConfigurationNode |
createNode(Object path) |
boolean |
equals(Object o) |
SimpleConfigurationNode |
getAppendedNode() |
protected SimpleConfigurationNode |
getChild(Object key,
boolean attach) |
List<? extends SimpleConfigurationNode> |
getChildrenList()
Return an immutable copy of the list of children this node is aware of
|
Map<Object,? extends SimpleConfigurationNode> |
getChildrenMap()
Return an immutable copy of the mapping from key to node of every child this node is aware of
|
Object |
getKey()
The key for this node.
|
<T> List<T> |
getList(Function<Object,T> transformer)
If this node has list values, this function unwraps them and converts them to an appropriate type based on the
provided function.
|
<T> List<T> |
getList(Function<Object,T> transformer,
List<T> def)
If this node has list values, this function unwraps them and converts them to an appropriate type based on the
provided function.
|
<T> List<T> |
getList(Function<Object,T> transformer,
Supplier<List<T>> defSupplier)
If this node has list values, this function unwraps them and converts them to an appropriate type based on the
provided function.
|
<T> List<T> |
getList(TypeToken<T> type,
List<T> def)
If this node has list values, this function unwraps them and converts them to an appropriate type based on the
provided type.
|
<T> List<T> |
getList(TypeToken<T> type,
Supplier<List<T>> defSupplier)
If this node has list values, this function unwraps them and converts them to an appropriate type based on the
provided type.
|
SimpleConfigurationNode |
getNode(Object... path)
Gets the node at the given (relative) path, possibly traversing multiple levels of nodes
|
ConfigurationOptions |
getOptions()
Return the options that currently apply to this node
|
SimpleConfigurationNode |
getParent()
Returns the current parent for this node.
|
Object[] |
getPath()
The full path from the root to this node.
|
<T> T |
getValue(Function<Object,T> transformer,
Supplier<T> defSupplier)
Gets the appropriately transformed typed version of this node's value from the provided transformation function
|
<T> T |
getValue(Function<Object,T> transformer,
T def)
Gets the appropriately transformed typed version of this node's value from the provided transformation function
|
Object |
getValue(Object def)
Get the current value associated with this node.
|
Object |
getValue(Supplier<Object> defSupplier)
Get the current value associated with this node.
|
<T> T |
getValue(TypeToken<T> type,
Supplier<T> defSupplier)
Get the current value associated with this node.
|
<T> T |
getValue(TypeToken<T> type,
T def)
Get the current value associated with this node.
|
int |
hashCode() |
boolean |
hasListChildren() |
boolean |
hasMapChildren() |
boolean |
isVirtual()
Whether this node does not currently exist in the configuration structure.
|
ConfigurationNode |
mergeValuesFrom(ConfigurationNode other)
Set all the values from the given node that are not present in this node
to their values in the provided node.
|
boolean |
removeChild(Object key)
Removes a direct child of this node
|
static SimpleConfigurationNode |
root() |
static SimpleConfigurationNode |
root(ConfigurationOptions options) |
SimpleConfigurationNode |
setValue(Object newValue)
Set this node's value to the given value.
|
String |
toString() |
protected SimpleConfigurationNode(Object key, SimpleConfigurationNode parent, ConfigurationOptions options)
public static SimpleConfigurationNode root()
public static SimpleConfigurationNode root(ConfigurationOptions options)
public Object getValue(Object def)
ConfigurationNode
getValue
in interface ConfigurationNode
def
- The default value to return if this node has no set valuedef
if there is nonepublic Object getValue(Supplier<Object> defSupplier)
ConfigurationNode
getValue
in interface ConfigurationNode
defSupplier
- The function that will be called to calculate a default value only if there is no existing
valuedef
if there is nonepublic <T> T getValue(Function<Object,T> transformer, T def)
ConfigurationNode
getValue
in interface ConfigurationNode
T
- The expected typetransformer
- The transformation functiondef
- The default value to return if this node has no set value or is not of a convertable typedef
either if no value is present or the value
could not be convertedpublic <T> T getValue(Function<Object,T> transformer, Supplier<T> defSupplier)
ConfigurationNode
getValue
in interface ConfigurationNode
T
- The expected typetransformer
- The transformation functiondefSupplier
- The function that will be called to calculate a default value only if there is no existing
value of the correct typedef
either if no value is present or the value
could not be convertedpublic <T> List<T> getList(Function<Object,T> transformer)
ConfigurationNode
getList
in interface ConfigurationNode
T
- The expected typetransformer
- The transformation functionpublic <T> List<T> getList(Function<Object,T> transformer, List<T> def)
ConfigurationNode
getList
in interface ConfigurationNode
T
- The expected typetransformer
- The transformation functiondef
- The default value if no appropriate value is setdef
if no
values could be convertedpublic <T> List<T> getList(Function<Object,T> transformer, Supplier<List<T>> defSupplier)
ConfigurationNode
getList
in interface ConfigurationNode
T
- The expected typetransformer
- The transformation functiondefSupplier
- The function that will be called to calculate a default value only if there is no existing
value of the correct typedef
if no
values could be convertedpublic <T> List<T> getList(TypeToken<T> type, List<T> def) throws ObjectMappingException
ConfigurationNode
getList
in interface ConfigurationNode
T
- The expected typetype
- The expected typedef
- The default value if no appropriate value is setdef
if no
values could be convertedObjectMappingException
public <T> List<T> getList(TypeToken<T> type, Supplier<List<T>> defSupplier) throws ObjectMappingException
ConfigurationNode
getList
in interface ConfigurationNode
T
- The expected typetype
- The expected typedefSupplier
- The function that will be called to calculate a default value only if there is no existing
value of the correct typedef
if no
values could be convertedObjectMappingException
public SimpleConfigurationNode setValue(Object newValue)
ConfigurationNode
Collection
or a Map
, it will be unwrapped into
the appropriate configuration node structuresetValue
in interface ConfigurationNode
newValue
- The value to setpublic <T> T getValue(TypeToken<T> type, T def) throws ObjectMappingException
ConfigurationNode
getValue
in interface ConfigurationNode
T
- the type to gettype
- The type to deserialize todef
- The value to return if no value or value is not of appropriate typedef
ObjectMappingException
public <T> T getValue(TypeToken<T> type, Supplier<T> defSupplier) throws ObjectMappingException
ConfigurationNode
getValue
in interface ConfigurationNode
T
- the type to gettype
- The type to deserialize todefSupplier
- The function that will be called to calculate a default value only if there is no existing
value of the correct typedef
ObjectMappingException
public ConfigurationNode mergeValuesFrom(ConfigurationNode other)
ConfigurationNode
mergeValuesFrom
in interface ConfigurationNode
other
- The node to merge values frompublic SimpleConfigurationNode getNode(Object... path)
ConfigurationNode
getNode
in interface ConfigurationNode
path
- The path to fetch the node atpublic boolean isVirtual()
ConfigurationNode
isVirtual
in interface ConfigurationNode
public boolean hasListChildren()
hasListChildren
in interface ConfigurationNode
public boolean hasMapChildren()
hasMapChildren
in interface ConfigurationNode
public List<? extends SimpleConfigurationNode> getChildrenList()
ConfigurationNode
getChildrenList
in interface ConfigurationNode
public Map<Object,? extends SimpleConfigurationNode> getChildrenMap()
ConfigurationNode
getChildrenMap
in interface ConfigurationNode
protected SimpleConfigurationNode getChild(Object key, boolean attach)
public boolean removeChild(Object key)
ConfigurationNode
removeChild
in interface ConfigurationNode
key
- The key of the node to removepublic SimpleConfigurationNode getAppendedNode()
getAppendedNode
in interface ConfigurationNode
public Object getKey()
ConfigurationNode
getKey
in interface ConfigurationNode
public Object[] getPath()
ConfigurationNode
getPath
in interface ConfigurationNode
public SimpleConfigurationNode getParent()
ConfigurationNode
getParent
in interface ConfigurationNode
public ConfigurationOptions getOptions()
ConfigurationNode
getOptions
in interface ConfigurationNode
protected SimpleConfigurationNode createNode(Object path)
protected void attachIfNecessary()
protected void attachChild(SimpleConfigurationNode child)
protected void clear()
Copyright © 2014–2017. All rights reserved.