Enum Outcome
- java.lang.Object
-
- java.lang.Enum<Outcome>
-
- com.google.javascript.jscomp.type.Outcome
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Outcome>
public enum Outcome extends java.lang.Enum<Outcome>
An enum for representing boolean outcomes. Currently they just represent typical booleans but this enum will be expanded to specifically differentiate between falsy and explicitly nullish values. e.g. 0 is falsy but not nullish.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Outcome
forBoolean(boolean val)
Gets the Outcome for the given boolean.abstract TernaryValue
isNullish()
Determines whether an Outcome enum value is nullish.abstract boolean
isTruthy()
Determines whether an Outcome enum value is truthy.abstract Outcome
not()
Gets thenot
ofthis
.static Outcome
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static Outcome[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static Outcome[] 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 (Outcome c : Outcome.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Outcome valueOf(java.lang.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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
isTruthy
public abstract boolean isTruthy()
Determines whether an Outcome enum value is truthy.
-
isNullish
public abstract TernaryValue isNullish()
Determines whether an Outcome enum value is nullish. Using TernaryValue instead of a boolean because 0 is Outcome.FALSE but not nullish so sometimes it is unclear.
-
not
public abstract Outcome not()
Gets thenot
ofthis
.
-
forBoolean
public static Outcome forBoolean(boolean val)
Gets the Outcome for the given boolean.
-
-