Class ChoiceInput<T>

java.lang.Object
com.ultikits.ultitools.ui.ChoiceInput<T>
Type Parameters:
T - value type
All Implemented Interfaces:
FormInput<T>

public final class ChoiceInput<T> extends Object implements FormInput<T>
Pick exactly one of several options. Value: the chosen option's value.
  • Field Details

    • key

      private final String key
    • label

      private final Text label
    • options

      private final List<ChoiceOption<T>> options
    • initial

      private final T initial
  • Constructor Details

  • Method Details

    • of

      public static <T> ChoiceInput<T> of(String key, Text label, List<ChoiceOption<T>> options)
      Uses the first option initially. @throws IllegalArgumentException if empty or values repeat
    • of

      public static <T> ChoiceInput<T> of(String key, Text label, List<ChoiceOption<T>> options, T initial)
      initial must be one of the options' values.
    • key

      public String key()
      Description copied from interface: FormInput
      Unique within its form; [a-z0-9_]+, at most 32 characters.
      Specified by:
      key in interface FormInput<T>
    • label

      public Text label()
      Description copied from interface: FormInput
      The deferred label.
      Specified by:
      label in interface FormInput<T>
    • options

      public List<ChoiceOption<T>> options()
      Options in display order; unmodifiable.
    • initial

      public T initial()
      The initial option value.
    • equals

      public boolean equals(@Nullable @Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object