Class Tree
java.lang.Object
org.polyfrost.oneconfig.api.config.v1.Node
org.polyfrost.oneconfig.api.config.v1.Tree
- All Implemented Interfaces:
Serializable
The Tree class represents a tree structure that contains properties and other trees as children
It provides methods to access and modify and compare the tree and its elements
It provides methods to access and modify and compare the tree and its elements
- See Also:
-
Field Summary
FieldsFields inherited from class org.polyfrost.oneconfig.api.config.v1.Node
description, LOGGER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidvoidclear()Clear this tree of all its members
This function is used internally to discard trees to prevent illegal usage of 'dead' treescollectFailures(@NotNull Runnable action) booleandeepEquals(@Nullable Object obj) Check if the tree contents equal another tree
This checks the values and children of the treebooleanstatic StringevaluatePath(Tree root, Node node) Figure out what the path from the given root to the given node is@Nullable Node@Nullable Node@Nullable NodegetOrPutChild(@NotNull String id) Property<?> Property<?> voidonAll(BiConsumer<String, Node> action) voidonAllProps(BiConsumer<String, Property<?>> action) voidoverwrite(@NotNull Node with, boolean preserveMissingOptions, boolean skipOverwritten, @Nullable Tree root) Overwrite all data in this node with the data from another node
For a node all metadata will be copied from the input onto this and any duplicate keys will be overwritten For aPropertythe value and callbacks and display conditions are copied onto this For aTreeall children and properties will be overwritten if they are present and this operation is recursivevoidoverwrite(Tree with, @NotNull Function<String, String> keyMapper, boolean preserveMissingOptions, boolean skipOverwritten, @Nullable Tree root) Overwrite this tree with the supplied tree using the keyMapper to map between key names from old to new if needed@Nullable NodetoString()static @NotNull Treetree()static @NotNull Treestatic @NotNull TreeCreate a new builder from the given tree
This will copy all the data from the tree into the builderunpack()Unpack this tree into a map of objects containing either more Maps or the values of the properties of this treeMethods inherited from class org.polyfrost.oneconfig.api.config.v1.Node
addMetadata, addMetadata, clearMetadata, consumeMetadata, getID, getMetadata, getMetadata, getOrPutMetadata, getTitle, hashCode, hasMetadata, overwrite, removeMetadata, setID, setTitle, strv
-
Field Details
-
map
-
-
Constructor Details
-
Tree
-
-
Method Details
-
beginFailureCollection
public static void beginFailureCollection() -
endFailureCollection
-
collectFailures
-
tree
-
tree
-
tree
Create a new builder from the given tree
This will copy all the data from the tree into the builder -
put
-
put
-
remove
-
set
-
get
-
get
-
get
-
getChild
-
getChild
-
getOrPutChild
-
getProp
-
getProp
-
onAll
-
onAllProps
-
equals
-
deepEquals
Check if the tree contents equal another tree
This checks the values and children of the tree- Specified by:
deepEqualsin classNode- Parameters:
obj- the tree to check against- Returns:
- whether the trees are equal
-
overwrite
public void overwrite(Tree with, @NotNull @NotNull Function<String, String> keyMapper, boolean preserveMissingOptions, boolean skipOverwritten, @Nullable @Nullable Tree root) Overwrite this tree with the supplied tree using the keyMapper to map between key names from old to new if needed- Parameters:
with- the tree to overwrite withkeyMapper- the key mapper function to use
-
overwrite
public void overwrite(@NotNull @NotNull Node with, boolean preserveMissingOptions, boolean skipOverwritten, @Nullable @Nullable Tree root) Description copied from class:NodeOverwrite all data in this node with the data from another node- For a node all metadata will be copied from the input onto this and any duplicate keys will be overwritten
- For a
Propertythe value and callbacks and display conditions are copied onto this - For a
Treeall children and properties will be overwritten if they are present and this operation is recursive
- Specified by:
overwritein classNode- Parameters:
with- the node to overwrite this withpreserveMissingOptions- if true then any properties missing in THIS tree that are present in the input tree will be added to this treeskipOverwritten- **DEPENDS ON PARAM "ROOT" BEING NOT NULL** skips being overwritten if a child node has already been marked as overwritten in the root treeroot- The root tree used to mark overwritten nodes for skipOverwritten
May be null if skipOverwritten is false
-
unpack
Unpack this tree into a map of objects containing either more Maps or the values of the properties of this tree -
toString
-
contentToString
-
clear
@Internal public void clear()Clear this tree of all its members
This function is used internally to discard trees to prevent illegal usage of 'dead' trees -
evaluatePath
Figure out what the path from the given root to the given node is
-