Class NodeTree
- java.lang.Object
-
- ca.stellardrift.permissionsex.util.NodeTree
-
-
Field Summary
Fields Modifier and Type Field Description static intPERMISSION_UNDEFINED
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleananyInPrefixMatching(String prefix, IntPredicate test)Return whether the nodeprefixor any of its children match the predicatetest.Map<String,Integer>asMap()Convert this node tree into a map of the defined nodes in this tree.intget(String node)Returns the value assigned to a specific node, or the nearest parent value in the tree if the node itself is undefined.static NodeTreeof(Map<String,Integer> values)Create a new node tree with the given values, and a default value of UNDEFINED.static NodeTreeof(Map<String,Integer> values, int defaultValue)Create a new node tree with the given values, and the specified root fallback value.StringtoString()NodeTreewithAll(Map<String,Integer> values)Return a modified new node tree with the specified values set.NodeTreewithValue(String node, int value)Return a new NodeTree instance with a single changed value.
-
-
-
Field Detail
-
PERMISSION_UNDEFINED
public static final int PERMISSION_UNDEFINED
- See Also:
- Constant Field Values
-
-
Method Detail
-
of
public static NodeTree of(Map<String,Integer> values)
Create a new node tree with the given values, and a default value of UNDEFINED.- Parameters:
values- The values to set- Returns:
- The new node tree
- Since:
- 2.0.0
-
of
public static NodeTree of(Map<String,Integer> values, int defaultValue)
Create a new node tree with the given values, and the specified root fallback value.- Parameters:
values- The values to be contained in this node treedefaultValue- The fallback value for any completely undefined nodes- Returns:
- The newly created node tree
- Since:
- 2.0.0
-
get
public int get(String node)
Returns the value assigned to a specific node, or the nearest parent value in the tree if the node itself is undefined.- Parameters:
node- The path to get the node value at- Returns:
- The int value for the given node
- Since:
- 2.0.0
-
anyInPrefixMatching
public boolean anyInPrefixMatching(String prefix, IntPredicate test)
Return whether the nodeprefixor any of its children match the predicatetest.- Parameters:
prefix- the prefix to testtest- the test function- Returns:
- if any values return true
-
asMap
public Map<String,Integer> asMap()
Convert this node tree into a map of the defined nodes in this tree.- Returns:
- An immutable map representation of the nodes defined in this tree
- Since:
- 2.0.0
-
withValue
public NodeTree withValue(String node, int value)
Return a new NodeTree instance with a single changed value.- Parameters:
node- The node path to change the value ofvalue- The value to change, or UNDEFINED to remove- Returns:
- The new, modified node tree
- Since:
- 2.0.0
-
withAll
public NodeTree withAll(Map<String,Integer> values)
Return a modified new node tree with the specified values set.- Parameters:
values- The values to set- Returns:
- The new node tree
- Since:
- 2.0.0
-
-