Class PermissionBackendCondition

    • Constructor Detail

      • PermissionBackendCondition

        public PermissionBackendCondition()
    • Method Detail

      • set

        public void set​(boolean val)
        Assign a specific testOrFalse result to this condition.

        By setting the condition to a specific value the condition will bypass calling PermissionBackend during value(), and immediately return the set value instead.

        Parameters:
        val - value to return from value().
      • evaluatesTrivially

        public boolean evaluatesTrivially()
        Description copied from class: BooleanCondition
        Check if the condition evaluates to either true or false without providing additional information to the evaluation tree, e.g. through checks to a remote service such as PermissionBackend.

        In this case, the tree can be reduced to skip all non-trivial checks resulting in a performance gain.

        Specified by:
        evaluatesTrivially in class BooleanCondition
      • reduce

        public BooleanCondition reduce()
        Description copied from class: BooleanCondition
        Reduce evaluation tree by cutting off branches that evaluate trivially and replacing them with a leave note corresponding to the value the branch evaluated to.

        
         Example 1 (T=True, F=False, C=non-trivial check):
              OR
             /  \    =>    T
            C   T
         Example 2 (cuts off a not-trivial check):
              AND
             /  \    =>    F
            C   F
         Example 3:
              AND
             /  \    =>    F
            T   F
         

        There is no guarantee that the resulting tree is minimal. The only guarantee made is that branches that evaluate trivially will be cut off and replaced by primitive values.

        Specified by:
        reduce in class BooleanCondition