Package org.apache.flink.util
Enum TernaryBoolean
- java.lang.Object
-
- java.lang.Enum<TernaryBoolean>
-
- org.apache.flink.util.TernaryBoolean
-
- All Implemented Interfaces:
Serializable
,Comparable<TernaryBoolean>
@PublicEvolving public enum TernaryBoolean extends Enum<TernaryBoolean>
A ternary boolean, which can have the values 'true', 'false', or 'undefined'.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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Enum Constant Detail
-
TRUE
public static final TernaryBoolean TRUE
The value for 'true'.
-
FALSE
public static final TernaryBoolean FALSE
The value for 'false'.
-
UNDEFINED
public static final TernaryBoolean UNDEFINED
The value for 'undefined'. In a configuration setting, this typically means that the default value will be used, or the value from a deployment-wide configuration.
-
-
Method Detail
-
values
public static TernaryBoolean[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (TernaryBoolean c : TernaryBoolean.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static TernaryBoolean valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
getOrDefault
public boolean getOrDefault(boolean defaultValue)
Gets the boolean value corresponding to this value. If this is the 'undefined' value, the method returns the given default.- Parameters:
defaultValue
- The value to be returned in case this ternary value is 'undefined'.
-
resolveUndefined
public TernaryBoolean resolveUndefined(boolean valueForUndefined)
Gets the boolean value corresponding to this value. If this is the 'UNDEFINED' value, the method returns the given valueForUndefined.- Parameters:
valueForUndefined
- The value to be returned in case this ternary value is 'undefined'.
-
getAsBoolean
@Nullable public Boolean getAsBoolean()
Gets this ternary boolean as a boxed boolean. The value 'undefined' results in 'null.
-
mergeTernaryBooleanWithConfig
public 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.- Parameters:
original
- the value to merge with the config.configOption
- the config option to merge with from the config.config
- the config to merge with.
-
fromBoolean
public static TernaryBoolean fromBoolean(boolean bool)
-
fromBoxedBoolean
public static TernaryBoolean fromBoxedBoolean(@Nullable Boolean bool)
-
-