Enum Class Outcome

java.lang.Object
java.lang.Enum<Outcome>
com.google.javascript.rhino.Outcome
All Implemented Interfaces:
Serializable, Comparable<Outcome>, Constable

public enum Outcome extends 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 Details

    • 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 Details

    • values

      public static Outcome[] 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

      public static Outcome valueOf(String name)
      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 name
      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 the not of this.
    • forBoolean

      public static Outcome forBoolean(boolean val)
      Gets the Outcome for the given boolean.