@PublicEvolving public enum TernaryBoolean extends Enum<TernaryBoolean>
A ternary boolean can for example be used to configuration switches that may be not configured (undefined), in which case a default value should be assumed.
Enum Constant and Description |
---|
FALSE
The value for 'false'.
|
TRUE
The value for 'true'.
|
UNDEFINED
The value for 'undefined'.
|
Modifier and Type | Method and Description |
---|---|
static TernaryBoolean |
fromBoolean(boolean bool)
|
static TernaryBoolean |
fromBoxedBoolean(Boolean bool)
Converts the given boxed Boolean to a TernaryBoolean.
|
Boolean |
getAsBoolean()
Gets this ternary boolean as a boxed boolean.
|
boolean |
getOrDefault(boolean defaultValue)
Gets the boolean value corresponding to this value.
|
static TernaryBoolean |
mergeTernaryBooleanWithConfig(TernaryBoolean original,
ConfigOption<Boolean> configOption,
ReadableConfig config)
Merges an existing value with a config, accepting the config's value only if the existing
value is undefined.
|
TernaryBoolean |
resolveUndefined(boolean valueForUndefined)
Gets the boolean value corresponding to this value.
|
static TernaryBoolean |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static TernaryBoolean[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final TernaryBoolean TRUE
public static final TernaryBoolean FALSE
public static final TernaryBoolean UNDEFINED
public static TernaryBoolean[] values()
for (TernaryBoolean c : TernaryBoolean.values()) System.out.println(c);
public static TernaryBoolean 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 boolean getOrDefault(boolean defaultValue)
defaultValue
- The value to be returned in case this ternary value is 'undefined'.public TernaryBoolean resolveUndefined(boolean valueForUndefined)
valueForUndefined
- The value to be returned in case this ternary value is 'undefined'.@Nullable public Boolean getAsBoolean()
public static TernaryBoolean mergeTernaryBooleanWithConfig(TernaryBoolean original, ConfigOption<Boolean> configOption, ReadableConfig config)
original
- the value to merge with the config.configOption
- the config option to merge with from the config.config
- the config to merge with.public static TernaryBoolean fromBoolean(boolean bool)
public static TernaryBoolean fromBoxedBoolean(@Nullable Boolean bool)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.