Class PermissionBackendCondition
- java.lang.Object
-
- com.google.gerrit.extensions.conditions.BooleanCondition
-
- com.google.gerrit.extensions.conditions.PrivateInternals_BooleanCondition.SubclassOnlyInCoreServer
-
- com.google.gerrit.server.permissions.PermissionBackendCondition
-
- Direct Known Subclasses:
PermissionBackendCondition.ForChange
,PermissionBackendCondition.ForProject
,PermissionBackendCondition.ForRef
,PermissionBackendCondition.WithUser
public abstract class PermissionBackendCondition extends PrivateInternals_BooleanCondition.SubclassOnlyInCoreServer
BooleanCondition
to evaluate a permission.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PermissionBackendCondition.ForChange
static class
PermissionBackendCondition.ForProject
static class
PermissionBackendCondition.ForRef
static class
PermissionBackendCondition.WithUser
-
Field Summary
-
Fields inherited from class com.google.gerrit.extensions.conditions.BooleanCondition
FALSE, TRUE
-
-
Constructor Summary
Constructors Constructor Description PermissionBackendCondition()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
evaluatesTrivially()
Check if the condition evaluates to eithertrue
orfalse
without providing additional information to the evaluation tree, e.g.BooleanCondition
reduce()
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.void
set(boolean val)
Assign a specifictestOrFalse
result to this condition.abstract String
toString()
-
Methods inherited from class com.google.gerrit.extensions.conditions.PrivateInternals_BooleanCondition.SubclassOnlyInCoreServer
children
-
-
-
-
Method Detail
-
set
public void set(boolean val)
Assign a specifictestOrFalse
result to this condition.By setting the condition to a specific value the condition will bypass calling
PermissionBackend
duringvalue()
, and immediately return the set value instead.- Parameters:
val
- value to return fromvalue()
.
-
evaluatesTrivially
public boolean evaluatesTrivially()
Description copied from class:BooleanCondition
Check if the condition evaluates to eithertrue
orfalse
without providing additional information to the evaluation tree, e.g. through checks to a remote service such asPermissionBackend
.In this case, the tree can be reduced to skip all non-trivial checks resulting in a performance gain.
- Specified by:
evaluatesTrivially
in classBooleanCondition
-
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 classBooleanCondition
-
-