public class KeyTree.Node extends Object implements Iterable<KeyTree.Node>
Modifier and Type | Field and Description |
---|---|
protected List<KeyTree.Node> |
children |
protected String |
comment |
protected Integer |
elementIndex |
protected int |
indent |
protected Map<Integer,KeyTree.Node> |
indexByElementIndex |
protected Map<String,KeyTree.Node> |
indexByName |
protected boolean |
isList |
protected Integer |
listSize |
protected String |
name |
protected KeyTree.Node |
parent |
protected Map<String,KeyTree.Node> |
priorityIndex |
protected String |
sideComment |
Modifier and Type | Method and Description |
---|---|
KeyTree.Node |
add(int indent,
String key) |
protected KeyTree.Node |
add(int indent,
String key,
boolean priority) |
KeyTree.Node |
add(String key) |
protected KeyTree.Node |
add(String key,
boolean priority) |
protected void |
checkList() |
List<KeyTree.Node> |
children() |
void |
clear() |
boolean |
clearIf(Predicate<KeyTree.Node> condition) |
protected boolean |
clearIf(Predicate<KeyTree.Node> condition,
boolean removeFromParent) |
protected void |
clearNode() |
Set<Map.Entry<String,KeyTree.Node>> |
entries() |
KeyTree.Node |
get(int i)
Get a child from its index.
|
KeyTree.Node |
get(String path)
Get a child from its path.
|
protected KeyTree.Node |
get(String path,
boolean add,
boolean priority)
Get a child from its path, or optionally add a new one if it is not created.
|
String |
getComment() |
KeyTree.Node |
getElement(int i)
Get a child list element from its index.
|
protected KeyTree.Node |
getElement(int i,
boolean add)
Get a child list element from its index, or optionally add a new one if it is not created.
|
Integer |
getElementIndex() |
KeyTree.Node |
getFirst() |
int |
getIndentation() |
KeyTree.Node |
getLast() |
Integer |
getListSize() |
String |
getName() |
KeyTree.Node |
getParent() |
String |
getPath() |
String |
getPathWithName() |
KeyTree.Node |
getPriority(String path)
Get a child from its path.
|
String |
getSideComment() |
Object |
getValue() |
boolean |
hasChildren() |
boolean |
isFirstNode() |
boolean |
isList() |
void |
isList(int listSize) |
boolean |
isRootNode() |
Iterator<KeyTree.Node> |
iterator() |
Set<String> |
keys() |
void |
setComment(String comment) |
void |
setElementIndex(int elementIndex) |
protected void |
setPriority(String key,
KeyTree.Node child) |
void |
setSideComment(String sideComment) |
int |
size() |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected final KeyTree.Node parent
protected String name
protected int indent
protected List<KeyTree.Node> children
protected Map<String,KeyTree.Node> indexByName
protected Map<String,KeyTree.Node> priorityIndex
protected Map<Integer,KeyTree.Node> indexByElementIndex
protected String comment
protected String sideComment
protected boolean isList
protected Integer listSize
protected Integer elementIndex
public String getName()
public String getComment()
public void setComment(String comment)
public String getSideComment()
public void setSideComment(String sideComment)
public KeyTree.Node getParent()
public boolean isRootNode()
public boolean isFirstNode()
public int getIndentation()
protected KeyTree.Node get(String path, boolean add, boolean priority)
path
- the path of children names to look for separated by KeyTree.options()
ConfigurationOptions.pathSeparator()
add
- if a new node must be added if it does not existpriority
- if true the priority index is used to allow specific repetitions on list values (manually added), otherwise all nodes are allowed (loaded)public KeyTree.Node get(String path)
path
- the path of names to look for separated by KeyTree.options()
ConfigurationOptions.pathSeparator()
public KeyTree.Node getPriority(String path)
add(String)
.path
- the path of names to look for separated by KeyTree.options()
ConfigurationOptions.pathSeparator()
protected KeyTree.Node getElement(int i, boolean add)
If i
is negative then gets the child at index size()
+ i
Example: node.get(-1)
gets the last child of node
i
- the index of the childadd
- if a new node must be added if it does not existpublic KeyTree.Node getElement(int i)
If i
is negative then gets the child element indexed by size()
+ i
Example: node.get(-1)
gets the last child element of the node
list.
i
- the index of the child elementpublic KeyTree.Node get(int i)
If i
is negative then gets the child at index size()
+ i
Example: node.get(-1)
gets the last child of node
i
- the index of the childpublic KeyTree.Node getFirst()
public KeyTree.Node getLast()
public KeyTree.Node add(String key)
public KeyTree.Node add(int indent, String key)
protected KeyTree.Node add(String key, boolean priority)
protected KeyTree.Node add(int indent, String key, boolean priority)
protected void setPriority(String key, KeyTree.Node child)
protected void checkList()
public Object getValue()
public boolean hasChildren()
public List<KeyTree.Node> children()
public Set<Map.Entry<String,KeyTree.Node>> entries()
public int size()
public boolean isList()
public void isList(int listSize)
public Integer getListSize()
public void setElementIndex(int elementIndex)
public Integer getElementIndex()
public String getPath()
public String getPathWithName()
protected void clearNode()
protected boolean clearIf(Predicate<KeyTree.Node> condition, boolean removeFromParent)
public boolean clearIf(Predicate<KeyTree.Node> condition)
public void clear()
public Iterator<KeyTree.Node> iterator()
iterator
in interface Iterable<KeyTree.Node>
Copyright © 2023. All rights reserved.