Enum Class Tristate

java.lang.Object
java.lang.Enum<Tristate>
org.spongepowered.api.util.Tristate
All Implemented Interfaces:
Serializable, Comparable<Tristate>, Constable

public enum Tristate extends Enum<Tristate>
Represents a simple tristate.
  • Enum Constant Details

    • TRUE

      public static final Tristate TRUE
    • FALSE

      public static final Tristate FALSE
    • UNDEFINED

      public static final Tristate UNDEFINED
  • Method Details

    • values

      public static Tristate[] 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 Tristate 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
    • fromBoolean

      public static Tristate fromBoolean(boolean val)
      Returns the appropriate tristate for a given boolean value.
      Parameters:
      val - The boolean value
      Returns:
      The appropriate tristate
    • fromNullableBoolean

      public static Tristate fromNullableBoolean(@Nullable Boolean val)
      Returns the appropriate tristate for a given nullable boolean value, where null equates to UNDEFINED.
      Parameters:
      val - The nullable boolean value
      Returns:
      The appropriate tristate
    • and

      public abstract Tristate and(Tristate other)
      ANDs this tristate with another tristate.
      Parameters:
      other - The tristate to AND with
      Returns:
      The result
    • or

      public abstract Tristate or(Tristate other)
      ORs this tristate with another tristate.
      Parameters:
      other - The tristate to OR with
      Returns:
      The result
    • not

      public abstract Tristate not()
      Negates this tristate.
      Returns:
      The result
    • asBoolean

      public boolean asBoolean()
      Returns the boolean representation of this tristate.
      Returns:
      The boolean tristate representation
    • asNullableBoolean

      public @Nullable Boolean asNullableBoolean()
      Returns the nullable boolean representation of this tristate, where UNDEFINED equates to null.

      Note: To ensure that there is a one-to-one mapping of nullable booleans to and from Tristate, this method will return null rather than use an Optional.

      Returns:
      The nullable boolean tristate representation