Package dev.polv.taleapi.permission
Enum Class Tristate
- All Implemented Interfaces:
Serializable,Comparable<Tristate>,Constable
Represents a tri-valued permission state.
Unlike a simple boolean, Tristate provides three distinct states:
ALLOW- Permission is explicitly grantedDENY- Permission is explicitly deniedUNDEFINED- No explicit permission set (inherit from parent/default)
Why Tristate?
A binary true/false system cannot distinguish between "denied" and "not set". This distinction is crucial for permission inheritance:
- UNDEFINED permissions inherit from parent groups
- DENY permissions block inheritance even if a parent allows it
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionbooleanConverts this tristate to a boolean value.booleanasBoolean(boolean defaultValue) Converts this tristate to a boolean with a default for UNDEFINED.static TristatefromBoolean(boolean value) Creates a Tristate from a boolean value.static TristatefromNullableBoolean(Boolean value) Creates a Tristate from a nullable Boolean.booleanReturns whether this state is defined (not UNDEFINED).static TristateReturns the enum constant of this class with the specified name.static Tristate[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ALLOW
Permission is explicitly granted. -
DENY
Permission is explicitly denied. -
UNDEFINED
No explicit permission set - inherit from parent or use default.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
asBoolean
public boolean asBoolean()Converts this tristate to a boolean value.- Returns:
trueif ALLOW,falseotherwise
-
asBoolean
public boolean asBoolean(boolean defaultValue) Converts this tristate to a boolean with a default for UNDEFINED.- Parameters:
defaultValue- the value to return if this is UNDEFINED- Returns:
trueif ALLOW,falseif DENY, or defaultValue if UNDEFINED
-
fromBoolean
Creates a Tristate from a boolean value. -
fromNullableBoolean
Creates a Tristate from a nullable Boolean. -
isDefined
public boolean isDefined()Returns whether this state is defined (not UNDEFINED).- Returns:
trueif this is ALLOW or DENY
-