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

      Nested Classes 
      Modifier and Type Interface Description
      static interface  NodeTree.Factory  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​java.lang.Boolean> asMap()
      Convert this node tree into a map of the defined nodes in this tree.
      Tristate get​(java.lang.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 NodeTree of​(java.util.Map<java.lang.String,​java.lang.Boolean> values)
      Create a new node tree with the given values, and a default value of Tristate.UNDEFINED.
      static NodeTree of​(java.util.Map<java.lang.String,​java.lang.Boolean> values, Tristate defaultValue)
      Create a new node tree with the given values, and the specified root fallback value.
      static NodeTree ofTristates​(java.util.Map<java.lang.String,​Tristate> values)
      Create a new node tree with the given values, and a default value of Tristate.UNDEFINED.
      static NodeTree ofTristates​(java.util.Map<java.lang.String,​Tristate> values, Tristate defaultValue)
      Create a new node tree with the given values, and the specified root fallback value.
      Tristate rootValue()
      Get the value of the root node in this tree.
      NodeTree withAll​(java.util.Map<java.lang.String,​java.lang.Boolean> values)
      Return a modified new node tree with the specified values set.
      NodeTree withAllTristates​(java.util.Map<java.lang.String,​Tristate> values)
      Return a modified new node tree with the specified values set.
      NodeTree withRootValue​(Tristate state)
      Return a modified tree with the provided root node value.
      NodeTree withValue​(java.lang.String node, Tristate value)
      Return a new NodeTree instance with a single changed value.
    • Method Detail

      • of

        static NodeTree of​(java.util.Map<java.lang.String,​java.lang.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​(java.util.Map<java.lang.String,​java.lang.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​(java.util.Map<java.lang.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​(java.util.Map<java.lang.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​(java.lang.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

        java.util.Map<java.lang.String,​java.lang.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​(java.lang.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​(java.util.Map<java.lang.String,​java.lang.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​(java.util.Map<java.lang.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