Package org.spongepowered.api.util
Enum Class Tristate
- All Implemented Interfaces:
Serializable
,Comparable<Tristate>
,Constable
Represents a simple tristate.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract Tristate
ANDs this tristate with another tristate.boolean
Returns the boolean representation of this tristate.@Nullable Boolean
Returns the nullable boolean representation of this tristate, whereUNDEFINED
equates to null.static Tristate
fromBoolean
(boolean val) Returns the appropriate tristate for a given boolean value.static Tristate
fromNullableBoolean
(@Nullable Boolean val) Returns the appropriate tristate for a given nullable boolean value, where null equates toUNDEFINED
.abstract Tristate
not()
Negates this tristate.abstract Tristate
ORs this tristate with another tristate.static Tristate
Returns 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
-
TRUE
-
FALSE
-
UNDEFINED
-
-
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
-
fromBoolean
Returns the appropriate tristate for a given boolean value.- Parameters:
val
- The boolean value- Returns:
- The appropriate tristate
-
fromNullableBoolean
Returns the appropriate tristate for a given nullable boolean value, where null equates toUNDEFINED
.- Parameters:
val
- The nullable boolean value- Returns:
- The appropriate tristate
-
and
ANDs this tristate with another tristate.- Parameters:
other
- The tristate to AND with- Returns:
- The result
-
or
ORs this tristate with another tristate.- Parameters:
other
- The tristate to OR with- Returns:
- The result
-
not
Negates this tristate.- Returns:
- The result
-
asBoolean
public boolean asBoolean()Returns the boolean representation of this tristate.- Returns:
- The boolean tristate representation
-
asNullableBoolean
Returns the nullable boolean representation of this tristate, whereUNDEFINED
equates to null.Note: To ensure that there is a one-to-one mapping of nullable booleans to and from
Tristate
, this method will return null rather than use anOptional
.- Returns:
- The nullable boolean tristate representation
-