Package org.openapitools.codegen.utils
Enum TriStateBoolean
- java.lang.Object
-
- java.lang.Enum<TriStateBoolean>
-
- org.openapitools.codegen.utils.TriStateBoolean
-
- All Implemented Interfaces:
Serializable,Comparable<TriStateBoolean>
public enum TriStateBoolean extends Enum<TriStateBoolean>
A tri-state toggle for boolean-like config options that need to distinguish "the user never set this" from an explicittrue/false, e.g. so a weak default can be applied along with a one-time warning when the option was left unset, while an explicitfalsesilently keeps the same default behavior.This replaces the previous convention of using a boxed
Booleanfield wherenullmeant "unset", which requires a code comment at every declaration site to be understandable.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TriStateBooleanfromNullableBoolean(Boolean value)Convert a nullableBoolean(the CLI/config-option convention wherenullmeans "not present in additionalProperties") into aTriStateBoolean.booleanisTrue()Whether this state represents an explicit, affirmative opt-in (TRUE).booleanisUnset()Whether the option was never explicitly set (UNSET).static TriStateBooleanvalueOf(String name)Returns the enum constant of this type with the specified name.static TriStateBoolean[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
UNSET
public static final TriStateBoolean UNSET
The option was never explicitly set by the user (neithertruenorfalse).
-
FALSE
public static final TriStateBoolean FALSE
The option was explicitly set tofalse.
-
TRUE
public static final TriStateBoolean TRUE
The option was explicitly set totrue.
-
-
Method Detail
-
values
public static TriStateBoolean[] 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 (TriStateBoolean c : TriStateBoolean.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static TriStateBoolean 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
-
isTrue
public boolean isTrue()
Whether this state represents an explicit, affirmative opt-in (TRUE).
-
isUnset
public boolean isUnset()
Whether the option was never explicitly set (UNSET).
-
fromNullableBoolean
public static TriStateBoolean fromNullableBoolean(Boolean value)
Convert a nullableBoolean(the CLI/config-option convention wherenullmeans "not present in additionalProperties") into aTriStateBoolean.
-
-