public class ConfigNode
extends java.lang.Object
Based on https://github.com/Rsl1122/Abstract-Plugin-Framework/blob/72e221d3571ef200727713d10d3684c51e9f469d/AbstractPluginFramework/api/src/main/java/com/djrapitops/plugin/config/ConfigNode.java
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,ConfigNode> |
childNodes |
protected java.util.List<java.lang.String> |
comment |
protected java.lang.String |
key |
protected java.util.List<java.lang.String> |
nodeOrder |
protected ConfigNode |
parent |
protected java.lang.String |
value |
Constructor and Description |
---|
ConfigNode(java.lang.String key,
ConfigNode parent,
java.lang.String value) |
Modifier and Type | Method and Description |
---|---|
protected ConfigNode |
addChild(ConfigNode child)
Add a new child ConfigNode.
|
ConfigNode |
addNode(java.lang.String path) |
boolean |
contains(java.lang.String path) |
void |
copyAll(ConfigNode from) |
void |
copyMissing(ConfigNode from) |
boolean |
equals(java.lang.Object o) |
boolean |
getBoolean() |
boolean |
getBoolean(java.lang.String path) |
java.util.List<java.lang.String> |
getComment() |
java.lang.Integer |
getInteger() |
java.lang.Integer |
getInteger(java.lang.String path) |
java.lang.String |
getKey(boolean deep) |
java.lang.Long |
getLong() |
java.lang.Long |
getLong(java.lang.String path) |
java.util.Optional<ConfigNode> |
getNode(java.lang.String path) |
protected int |
getNodeDepth() |
protected java.util.List<java.lang.String> |
getNodeOrder() |
ConfigNode |
getParent() |
java.lang.String |
getString() |
java.lang.String |
getString(java.lang.String path) |
java.util.List<java.lang.String> |
getStringList() |
java.util.List<java.lang.String> |
getStringList(java.lang.String path) |
java.util.Map<java.lang.String,java.lang.String> |
getStringMap(boolean fullKeys)
Return values in a Map.
|
int |
hashCode() |
boolean |
isLeafNode() |
boolean |
moveChild(java.lang.String oldPath,
java.lang.String newPath)
Moves a node from old path to new path.
|
void |
remove() |
protected void |
removeChild(ConfigNode child) |
boolean |
removeNode(java.lang.String path)
Remove a node at a certain path.
|
void |
reorder(java.util.List<java.lang.String> newOrder) |
void |
save()
Find the root node and save.
|
<T> void |
set(java.lang.String path,
T value) |
<T> void |
set(T value) |
void |
setComment(java.util.List<java.lang.String> comment) |
void |
sort() |
java.lang.String |
toString() |
protected void |
updateParent(ConfigNode newParent) |
protected final java.lang.String key
protected ConfigNode parent
protected java.util.List<java.lang.String> nodeOrder
protected java.util.Map<java.lang.String,ConfigNode> childNodes
protected java.util.List<java.lang.String> comment
protected java.lang.String value
public ConfigNode(java.lang.String key, ConfigNode parent, java.lang.String value)
protected void updateParent(ConfigNode newParent)
public java.util.Optional<ConfigNode> getNode(java.lang.String path)
public boolean contains(java.lang.String path)
public ConfigNode addNode(java.lang.String path)
public boolean removeNode(java.lang.String path)
path
- Path to the node that is up for removal.true
if the node was present and is now removed. false
if the path did not have a node.public void remove()
protected ConfigNode addChild(ConfigNode child)
child
- ConfigNode to add.
If from another config tree, the parent is 'cut', which breaks the old tree traversal.protected void removeChild(ConfigNode child)
public boolean moveChild(java.lang.String oldPath, java.lang.String newPath)
oldPath
- Old path of the node.newPath
- New path of the node.true
if the move was successful. false
if the new node is not presentpublic java.lang.String getKey(boolean deep)
public void sort()
public void reorder(java.util.List<java.lang.String> newOrder)
public void save() throws java.io.IOException
java.io.IOException
- If the save can not be performed.public <T> void set(java.lang.String path, T value)
public <T> void set(T value)
public java.util.List<java.lang.String> getComment()
public void setComment(java.util.List<java.lang.String> comment)
public java.util.List<java.lang.String> getStringList()
public java.lang.Integer getInteger()
public java.lang.Long getLong()
public java.lang.String getString()
public boolean getBoolean()
public java.util.List<java.lang.String> getStringList(java.lang.String path)
public java.util.Map<java.lang.String,java.lang.String> getStringMap(boolean fullKeys)
fullKeys
- Should the key be full keys of the Config node.public java.lang.Integer getInteger(java.lang.String path)
public java.lang.Long getLong(java.lang.String path)
public java.lang.String getString(java.lang.String path)
public boolean getBoolean(java.lang.String path)
public void copyMissing(ConfigNode from)
public void copyAll(ConfigNode from)
protected int getNodeDepth()
public ConfigNode getParent()
public boolean isLeafNode()
protected java.util.List<java.lang.String> getNodeOrder()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object