Interface NodeTree
public interface NodeTree
An immutable tree structure for determining node data. Any changes will
create new copies of the necessary tree objects.
This class is simply provided as a utility for plugins implementing
PermissionService
. It is not a requirement that this class is used,
however the behaviour defined in Subject
regarding implicit node
inheritance should be maintained.
- Keys are case-insensitive.
- Segments of nodes are split by the '.' character
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionasMap()
Convert this node tree into a map of the defined nodes in this tree.Returns the value assigned to a specific node, or the nearest parent value in the tree if the node itself is undefined.static NodeTree
Create a new node tree with the given values, and a default value ofTristate.UNDEFINED
.static NodeTree
Create a new node tree with the given values, and the specified root fallback value.static NodeTree
ofTristates
(Map<String, Tristate> values) Create a new node tree with the given values, and a default value ofTristate.UNDEFINED
.static NodeTree
ofTristates
(Map<String, Tristate> values, Tristate defaultValue) Create a new node tree with the given values, and the specified root fallback value.Get the value of the root node in this tree.Return a modified new node tree with the specified values set.withAllTristates
(Map<String, Tristate> values) Return a modified new node tree with the specified values set.withRootValue
(Tristate state) Return a modified tree with the provided root node value.Return a new NodeTree instance with a single changed value.
-
Method Details
-
of
Create a new node tree with the given values, and a default value ofTristate.UNDEFINED
.- Parameters:
values
- The values to set- Returns:
- The new node tree
-
of
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
-
ofTristates
Create a new node tree with the given values, and a default value ofTristate.UNDEFINED
.- Parameters:
values
- The values to set- Returns:
- The new node tree
-
ofTristates
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
-
get
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 tristate value for the given node
-
rootValue
Tristate rootValue()Get the value of the root node in this tree.- Returns:
- the root node value
-
withRootValue
Return a modified tree with the provided root node value.- Parameters:
state
- the new state for the root node- Returns:
- a tree reflecting the changed state, leaving the receiver unmodified
-
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
-
withValue
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
-
withAll
Return a modified new node tree with the specified values set.- Parameters:
values
- The values to set- Returns:
- The new node tree
-
withAllTristates
Return a modified new node tree with the specified values set.- Parameters:
values
- The values to set- Returns:
- The new node tree
-