public enum TriState extends Enum<TriState>
Enum Constant and Description |
---|
DEFAULT
Represents a value that refers to a "default" value, often as a fallback.
|
FALSE
Represents the boolean value of
false . |
TRUE
Represents the boolean value of
true . |
Modifier and Type | Method and Description |
---|---|
boolean |
get()
Gets the value of the tri-state.
|
@Nullable Boolean |
getBoxed()
Gets the value of the tri-state as a boxed, nullable boolean.
|
<T> Optional<T> |
map(BooleanFunction<? extends T> mapper)
|
static TriState |
of(boolean bool)
Gets the corresponding tri-state from a boolean value.
|
static TriState |
of(@Nullable Boolean bool)
Gets a tri-state from a nullable boxed boolean.
|
boolean |
orElse(boolean value)
Gets the value of this tri-state.
|
boolean |
orElseGet(BooleanSupplier supplier)
Gets the value of this tri-state.
|
<X extends Throwable> |
orElseThrow(Supplier<X> exceptionSupplier)
Gets the value of this tri-state, or throws an exception if this tri-state's value is
DEFAULT . |
static TriState |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static TriState[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final TriState FALSE
false
.public static final TriState DEFAULT
public static final TriState TRUE
true
.public static TriState[] values()
for (TriState c : TriState.values()) System.out.println(c);
public static TriState valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static TriState of(boolean bool)
public static TriState of(@Nullable @Nullable Boolean bool)
public boolean get()
TRUE
.
Otherwise false.@Nullable public @Nullable Boolean getBoxed()
public boolean orElse(boolean value)
DEFAULT
then use the supplied value.value
- the value to fallback toDEFAULT
.public boolean orElseGet(BooleanSupplier supplier)
DEFAULT
then use the supplied value.supplier
- the supplier used to get the value to fallback toDEFAULT
.public <T> Optional<T> map(BooleanFunction<? extends T> mapper)
T
- the type of object being supplier by the mappermapper
- the mapper to useOptional.empty()
if the tri-state is DEFAULT
or the value provided by the mapper is null
.