Interface FormResponse


@NonExtendable public interface FormResponse
Submitted values of a Form. Immutable.
  • Method Details

    • get

      <T> T get(FormInput<T> input)
      The submitted value of input. Handles belong by identity, not by key or value equality. Two equal forms do not accept each other's handles: read values with the handles of the form that was shown.
      Type Parameters:
      T - input value type
      Throws:
      IllegalArgumentException - if input is not an input of the form that produced this
    • of

      static FormResponse of(Form form, Map<FormInput<?>, ?> values)
      Creates a response; for backends and tests. Every input of form needs exactly one value, keyed by that input's handle (by identity); foreign handles are rejected. Each value is checked against its input:
      • TextInput: a String of at most maxLength() characters (String.length()) with at most maxLines() - 1 line feeds;
      • ToggleInput: a Boolean;
      • ChoiceInput: equal to one option's value;
      • SliderInput: a finite Double no further than half a step outside [min, max]; it is stored snapped to the nearest min + k * step, and as max itself for the largest k, so get(FormInput) returns a value of the slider's documented form.
      A backend whose submitted answer this rejects must not complete the session with it: it logs one WARNING with the owner and reports closed(PLAYER).
      Throws:
      IllegalArgumentException - if a handle is missing or foreign, or a value fails its input's check
    • checkedValue

      private static Object checkedValue(FormInput<?> input, Object value)
    • snapped

      private static double snapped(SliderInput slider, double value)