Package org.apache.juneau.commons.lang
Enum Class TriState
- All Implemented Interfaces:
Serializable,Comparable<TriState>,Constable
Three-state enumeration for boolean-like values that can be explicitly set or unset.
This enum is useful in scenarios where you need to distinguish between:
- A value that is explicitly set to
true - A value that is explicitly set to
false - A value that is not set (should inherit from a parent/default)
Example:
-
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 TypeMethodDescriptionstatic TriStatefromBoolean(boolean value) Converts a boolean to a TriState.booleantoBoolean(boolean defaultValue) Converts this TriState to a boolean value.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
-
TRUE
Explicitly set totrue . -
FALSE
Explicitly set tofalse . -
UNSET
Not set - should inherit from parent or use default value.
-
-
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
-
toBoolean
Converts this TriState to a boolean value.If this is
UNSET, returns the provided default value. -
fromBoolean
Converts a boolean to a TriState.
-