Package org.incendo.cloud.permission
Interface PermissionResult
The cached result of a permission check, representing whether a command may be executed.
Implementations must be immutable. Most importantly, allowed() must always return the same value as previous
invocations.
Custom implementations may be used in order to provide more information. For example, the reason that the permission lookup returned false.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanallowed()Returnstrueif the command may be executed.static @NonNull PermissionResultallowed(@NonNull Permission permission) Creates a successful result for the given permission.default booleandenied()Returnstrueif the command may not be executed.static @NonNull PermissionResultdenied(@NonNull Permission permission) Creates a failed result for the given permission.static @NonNull PermissionResultof(boolean result, @NonNull Permission permission) Creates a result that wraps the given boolean result.Returns the permission that this result came from.
-
Method Details
-
allowed
boolean allowed()Returnstrueif the command may be executed.This always returns the opposite of
denied().- Returns:
trueif the command may be executed
-
denied
default boolean denied()Returnstrueif the command may not be executed.This always returns the opposite of
allowed().- Returns:
trueif the command may not be executed
-
permission
@NonNull Permission permission()Returns the permission that this result came from.- Returns:
- the permission that this result came from
-
of
Creates a result that wraps the given boolean result.- Parameters:
result- true if the command may be executed, false otherwisepermission- the permission that this result came from- Returns:
- a PermissionResult of the boolean result
-
allowed
Creates a successful result for the given permission.- Parameters:
permission- the permission that this result came from- Returns:
- a successful PermissionResult
-
denied
Creates a failed result for the given permission.- Parameters:
permission- the permission that this result came from- Returns:
- a failed PermissionResult
-