Record Class DialogResponse

java.lang.Object
java.lang.Record
fr.fidorial.dialog.DialogResponse

public record DialogResponse(CompoundBinaryTag values) extends Record
  • Field Details

    • EMPTY

      public static final DialogResponse EMPTY
      A response carrying nothing, as sent by a dialog with no input control.
      Since:
      0.1.0
  • Constructor Details

    • DialogResponse

      public DialogResponse(CompoundBinaryTag values)
      Creates an instance of a DialogResponse record class.
      Parameters:
      values - the value for the values record component
  • Method Details

    • text

      @Contract(pure=true) public Optional<String> text(String key)
      Reads a value as text.

      Numbers and booleans are rendered as their string form rather than rejected.

      Parameters:
      key - the input key to read
      Returns:
      the value, or empty when the payload holds nothing under that key
      Since:
      0.1.0
    • bool

      @Contract(pure=true) public Optional<Boolean> bool(String key)
      Reads a value as a flag.

      A checkbox arrives as a byte, but a text input configured with custom strings arrives as text, so "true" and "1" are accepted too.

      Parameters:
      key - the input key to read
      Returns:
      the value, or empty when the payload holds nothing readable under that key
      Since:
      0.1.0
    • number

      @Contract(pure=true) public OptionalDouble number(String key)
      Reads a value as a number.
      Parameters:
      key - the input key to read
      Returns:
      the value, or empty when the payload holds nothing numeric under that key
      Since:
      0.1.0
    • contains

      @Contract(pure=true) public boolean contains(String key)
      Returns whether the payload holds anything under key.
      Parameters:
      key - the input key to look up
      Returns:
      whether the payload holds anything under key
      Since:
      0.1.0
    • keys

      @Contract(pure=true) public Set<String> keys()
      Returns every key the payload carries.
      Returns:
      every key the payload carries
      Since:
      0.1.0
    • isEmpty

      @Contract(pure=true) public boolean isEmpty()
      Returns whether the payload is empty.
      Returns:
      whether the payload is empty
      Since:
      0.1.0
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • values

      public CompoundBinaryTag values()
      Returns the value of the values record component.
      Returns:
      the value of the values record component