Enum Class TriState

java.lang.Object
java.lang.Enum<TriState>
net.fabricmc.fabric.api.util.TriState
All Implemented Interfaces:
Serializable, Comparable<TriState>, Constable, net.minecraft.util.StringRepresentable

public enum TriState extends Enum<TriState> implements net.minecraft.util.StringRepresentable
Represents a boolean value which can be true, false or refer to a default value.
  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>

    Nested classes/interfaces inherited from interface net.minecraft.util.StringRepresentable

    net.minecraft.util.StringRepresentable.EnumCodec<E>, net.minecraft.util.StringRepresentable.StringRepresentableCodec<S>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Represents a value that refers to a "default" value, often as a fallback.
    Represents the boolean value of false.
    Represents the boolean value of true.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<TriState>
     

    Fields inherited from interface net.minecraft.util.StringRepresentable

    PRE_BUILT_MAP_THRESHOLD
  • Method Summary

    Modifier and Type
    Method
    Description
    static TriState
    Returns a parsed TriState from a system property.
    boolean
    get()
    Gets the value of the tri-state.
    @Nullable Boolean
    Gets the value of the tri-state as a boxed, nullable boolean.
    Value of this enum as string.
    <T> Optional<T>
    map(BooleanFunction<@Nullable ? extends T> mapper)
    Maps the boolean value of this tri-state if it is TRUE or FALSE.
    static TriState
    of(boolean bool)
    Gets the corresponding tri-state from a boolean value.
    static TriState
    of(@Nullable Boolean bool)
    Gets a tri-state from a nullable boxed boolean.
    boolean
    orElse(boolean value)
    Gets the value of this tri-state.
    boolean
    Gets the value of this tri-state.
    <X extends Throwable>
    boolean
    orElseThrow(Supplier<X> exceptionSupplier)
    Gets the value of this tri-state, or throws an exception if this tri-state's value is DEFAULT.
    static TriState
    Returns the enum constant of this class with the specified name.
    static TriState[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • FALSE

      public static final TriState FALSE
      Represents the boolean value of false.
    • DEFAULT

      public static final TriState DEFAULT
      Represents a value that refers to a "default" value, often as a fallback.
    • TRUE

      public static final TriState TRUE
      Represents the boolean value of true.
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<TriState> CODEC
  • 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
    • of

      public static TriState of(boolean bool)
      Gets the corresponding tri-state from a boolean value.
      Parameters:
      bool - the boolean value
      Returns:
      TRUE or FALSE depending on the value of the boolean.
    • of

      public static TriState of(@Nullable Boolean bool)
      Gets a tri-state from a nullable boxed boolean.
      Parameters:
      bool - the boolean value
      Returns:
      DEFAULT if null. Otherwise TRUE or FALSE depending on the value of the boolean.
    • get

      public boolean get()
      Gets the value of the tri-state.
      Returns:
      true if the tri-state is TRUE, otherwise false.
    • getBoxed

      public @Nullable Boolean getBoxed()
      Gets the value of the tri-state as a boxed, nullable boolean.
      Returns:
      null if DEFAULT. Otherwise true if TRUE or false if FALSE.
    • orElse

      public boolean orElse(boolean value)
      Gets the value of this tri-state. If the value is DEFAULT then use the supplied value.
      Parameters:
      value - the value to fall back to
      Returns:
      the value of the tri-state or the supplied value if DEFAULT.
    • orElseGet

      public boolean orElseGet(BooleanSupplier supplier)
      Gets the value of this tri-state. If the value is DEFAULT then use the supplied value.
      Parameters:
      supplier - the supplier used to get the value to fall back to
      Returns:
      the value of the tri-state or the value of the supplier if the tri-state is DEFAULT.
    • map

      public <T> Optional<T> map(BooleanFunction<@Nullable ? extends T> mapper)
      Maps the boolean value of this tri-state if it is TRUE or FALSE.
      Type Parameters:
      T - the type of object being supplier by the mapper
      Parameters:
      mapper - the mapper to use
      Returns:
      an optional containing the mapped value; Optional.empty() if the tri-state is DEFAULT or the value provided by the mapper is null.
    • orElseThrow

      public <X extends Throwable> boolean orElseThrow(Supplier<X> exceptionSupplier) throws X
      Gets the value of this tri-state, or throws an exception if this tri-state's value is DEFAULT.
      Type Parameters:
      X - Type of the exception to be thrown
      Parameters:
      exceptionSupplier - the supplying function that produces an exception to be thrown
      Returns:
      the value
      Throws:
      X - if the value is DEFAULT
    • fromSystemProperty

      public static TriState fromSystemProperty(String property)
      Returns a parsed TriState from a system property.
      Parameters:
      property - the system property
      Returns:
      a parsed TriState from a system property
    • getSerializedName

      public String getSerializedName()
      Value of this enum as string.
      Specified by:
      getSerializedName in interface net.minecraft.util.StringRepresentable
      Returns:
      lowercase name of the value.