Package com.google.javascript.rhino
Enum Class Outcome
- All Implemented Interfaces:
Serializable,Comparable<Outcome>,Constable
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionRepresents falsy values.Represents truthy values. -
Method Summary
Modifier and TypeMethodDescriptionstatic OutcomeforBoolean(boolean val) Gets the Outcome for the given boolean.abstract TriDetermines whether an Outcome enum value is nullish.abstract booleanisTruthy()Determines whether an Outcome enum value is truthy.abstract Outcomenot()Gets thenotofthis.static OutcomeReturns the enum constant of this class with the specified name.static Outcome[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
TRUE
Represents truthy values. For example: {}, true, 1, etc. -
FALSE
Represents falsy values. For examples: '', 0, false, null, etc. -
FALSE_NOT_NULL
-
NULLISH
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
-
isTruthy
public abstract boolean isTruthy()Determines whether an Outcome enum value is truthy. -
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
Gets thenotofthis. -
forBoolean
Gets the Outcome for the given boolean.
-