Package com.google.javascript.rhino
Enum Outcome
- java.lang.Object
-
- java.lang.Enum<Outcome>
-
- com.google.javascript.rhino.Outcome
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Outcome>
public enum Outcome extends java.lang.Enum<Outcome>
An enum for representing truthiness and nullishness of outcomes. The values are TRUE, FALSE, FALSE_NOT_NULL, and NULLISH. FALSE represents all falsy values so it contains both FALSE_NOT_NULL and NULLISH. It specifically differentiates between falsy and explicitly nullish values. e.g. 0 is falsy but not nullish.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description FALSE
Represents falsy values.FALSE_NOT_NULL
NULLISH
TRUE
Represents truthy values.
-
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 Tri
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.
-
-
-
Enum Constant Detail
-
TRUE
public static final Outcome TRUE
Represents truthy values. For example: {}, true, 1, etc.
-
FALSE
public static final Outcome FALSE
Represents falsy values. For examples: '', 0, false, null, etc.
-
FALSE_NOT_NULL
public static final Outcome FALSE_NOT_NULL
-
NULLISH
public static final Outcome NULLISH
-
-
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 Tri isNullish()
Determines whether an Outcome enum value is nullish. Using Tri 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.
-
-