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
  • Method Details

    • of

      static NodeTree of(Map<String,Boolean> values)
      Create a new node tree with the given values, and a default value of Tristate.UNDEFINED.
      Parameters:
      values - The values to set
      Returns:
      The new node tree
    • of

      static NodeTree of(Map<String,Boolean> values, Tristate 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 tree
      defaultValue - The fallback value for any completely undefined nodes
      Returns:
      The newly created node tree
    • ofTristates

      static NodeTree ofTristates(Map<String,Tristate> values)
      Create a new node tree with the given values, and a default value of Tristate.UNDEFINED.
      Parameters:
      values - The values to set
      Returns:
      The new node tree
    • ofTristates

      static NodeTree ofTristates(Map<String,Tristate> values, Tristate 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 tree
      defaultValue - The fallback value for any completely undefined nodes
      Returns:
      The newly created node tree
    • get

      Tristate 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 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

      NodeTree withRootValue(Tristate state)
      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

      Map<String,Boolean> 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

      NodeTree withValue(String node, Tristate value)
      Return a new NodeTree instance with a single changed value.
      Parameters:
      node - The node path to change the value of
      value - The value to change, or UNDEFINED to remove
      Returns:
      The new, modified node tree
    • withAll

      NodeTree withAll(Map<String,Boolean> values)
      Return a modified new node tree with the specified values set.
      Parameters:
      values - The values to set
      Returns:
      The new node tree
    • withAllTristates

      NodeTree withAllTristates(Map<String,Tristate> values)
      Return a modified new node tree with the specified values set.
      Parameters:
      values - The values to set
      Returns:
      The new node tree