public class SimpleConfigurationNode extends Object implements ConfigurationNode
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() |
boolean |
getBoolean()
Gets the value typed using the appropriate type conversion from
Types |
boolean |
getBoolean(boolean def)
Gets the value typed using the appropriate type conversion from
Types |
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
|
double |
getDouble()
Gets the value typed using the appropriate type conversion from
Types |
double |
getDouble(double def)
Gets the value typed using the appropriate type conversion from
Types |
float |
getFloat()
Gets the value typed using the appropriate type conversion from
Types |
float |
getFloat(float def)
Gets the value typed using the appropriate type conversion from
Types |
int |
getInt()
Gets the value typed using the appropriate type conversion from
Types |
int |
getInt(int def)
Gets the value typed using the appropriate type conversion from
Types |
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(TypeToken<T> type)
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,
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.
|
long |
getLong()
Gets the value typed using the appropriate type conversion from
Types |
long |
getLong(long def)
Gets the value typed using the appropriate type conversion from
Types |
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.
|
String |
getString()
Gets the value typed using the appropriate type conversion from
Types |
String |
getString(String def)
Gets the value typed using the appropriate type conversion from
Types |
Object |
getValue()
Get the current value associated with this node.
|
<T> T |
getValue(Function<Object,T> transformer)
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.
|
<T> T |
getValue(TypeToken<T> type)
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.
|
<T> ConfigurationNode |
setValue(TypeToken<T> type,
T value)
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()
ConfigurationNode
getValue
in interface ConfigurationNode
ConfigurationNode.getValue(Object)
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 <T> T getValue(Function<Object,T> transformer)
ConfigurationNode
getValue
in interface ConfigurationNode
T
- The expected typetransformer
- The transformation functionpublic <T> T getValue(Function<Object,T> transformer, T def)
ConfigurationNode
getValue
in interface ConfigurationNode
T
- The expected typetransformer
- The transformation functiondef
- The expected 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(TypeToken<T> type) throws ObjectMappingException
ConfigurationNode
getList
in interface ConfigurationNode
T
- The expected typetype
- The expected typeObjectMappingException
public <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 String getString()
ConfigurationNode
Types
getString
in interface ConfigurationNode
ConfigurationNode.getValue()
public String getString(String def)
ConfigurationNode
Types
getString
in interface ConfigurationNode
def
- The default value if no appropriate value is setdef
if no appropriate value is availableConfigurationNode.getValue()
public float getFloat()
ConfigurationNode
Types
getFloat
in interface ConfigurationNode
ConfigurationNode.getValue()
public float getFloat(float def)
ConfigurationNode
Types
getFloat
in interface ConfigurationNode
def
- The default value if no appropriate value is setdef
if no appropriate value is availableConfigurationNode.getValue()
public double getDouble()
ConfigurationNode
Types
getDouble
in interface ConfigurationNode
ConfigurationNode.getValue()
public double getDouble(double def)
ConfigurationNode
Types
getDouble
in interface ConfigurationNode
def
- The default value if no appropriate value is setdef
if no appropriate value is availableConfigurationNode.getValue()
public int getInt()
ConfigurationNode
Types
getInt
in interface ConfigurationNode
ConfigurationNode.getValue()
public int getInt(int def)
ConfigurationNode
Types
getInt
in interface ConfigurationNode
def
- The default value if no appropriate value is setdef
if no appropriate value is availableConfigurationNode.getValue()
public long getLong()
ConfigurationNode
Types
getLong
in interface ConfigurationNode
ConfigurationNode.getValue()
public long getLong(long def)
ConfigurationNode
Types
getLong
in interface ConfigurationNode
def
- The default value if no appropriate value is setdef
if no appropriate value is availableConfigurationNode.getValue()
public boolean getBoolean()
ConfigurationNode
Types
getBoolean
in interface ConfigurationNode
ConfigurationNode.getValue()
public boolean getBoolean(boolean def)
ConfigurationNode
Types
getBoolean
in interface ConfigurationNode
def
- The default value if no appropriate value is setdef
if no appropriate value is availableConfigurationNode.getValue()
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) throws ObjectMappingException
ConfigurationNode
getValue
in interface ConfigurationNode
T
- the type to gettype
- The type to deserialize toObjectMappingException
public <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 ordef
ObjectMappingException
public <T> ConfigurationNode setValue(TypeToken<T> type, T value) throws ObjectMappingException
ConfigurationNode
Collection
or a Map
, it will be unwrapped into
the appropriate configuration node structure.
This method will also perform serialization using the appropriate TypeSerializer for the given type, or casting if no type serializer is found.setValue
in interface ConfigurationNode
T
- The type to serialize totype
- The type to use for serialization type informationvalue
- The value to setObjectMappingException
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–2015 Leaping Ninja. All rights reserved.