Annotation Interface Input


@Documented @Target({METHOD,PARAMETER}) public @interface Input
Annotation used to specify an input. The property is extracted from Reacts underlying props object. By default the input is passed as a value in when creating the view but it can also be retrieved from the react context. When applied to an abstract method, the input is mutable. When applied to a constructor parameter, the input is immutable.

If applied to a method, the method that is annotated with this annotation must also comply with the following constraints:

  • Must not be annotated with any other react annotation
  • Must have 0 parameters
  • Must return a value
  • Must be an abstract instance method
  • Must not throw exceptions
  • Must be accessible from the same package as the class annotated by View
  • Should not be public as not expected to be invoked outside the view. A warning will be generated but can be suppressed by the SuppressWarnings or SuppressReact4jWarnings annotations with a key "React4j:PublicMethod". This warning is also suppressed by the annotation processor if it is implementing an interface method.
  • Should not be protected if in the class annotated with the View annotation as the method is not expected to be invoked outside the view. A warning will be generated but can be suppressed by the SuppressWarnings or SuppressReact4jWarnings annotations with a key "React4j:ProtectedMethod".
  • Nullness follows the declaring JSpecify scope. Use Nullable for nullable input values, or declare a NullMarked scope for non-null defaults. Legacy nullability annotations are ignored.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Interface supplying fluent default methods for this input's builder step.
    Class<? extends arez.EqualityComparator>
    Comparator defining changes to this mutable method input, including rendering, Arez invalidation and input-change callbacks.
    boolean
    Return true if the input value should be sourced from tree context rather than supplied when creating the view.
    Provider of this immutable constructor input's key contribution.
    Return the name of the input.
    Indicate whether the input should be annotated by Observable.
    Return the qualifier used to access value from context.
    Setting indicating whether the input should be supplied when the view is constructed.
  • Element Details

    • keyGenerator

      Class<?> keyGenerator
      Provider of this immutable constructor input's key contribution. The provider implements InputKeyGenerator for a compatible input type, including its nullness, and has an accessible no-argument constructor. Providers must be deterministic and have no observable side effects; the framework may reuse instances and invoke them repeatedly. Explicit providers override automatic key derivation. void.class uses automatic derivation.
      Returns:
      the key provider class.
      Default:
      void.class
    • equalityComparator

      Class<? extends arez.EqualityComparator> equalityComparator
      Comparator defining changes to this mutable method input, including rendering, Arez invalidation and input-change callbacks. An explicit comparator overrides the exact declared type's DefaultEqualityComparator. Without either selection, JavaScript strict equality is used. Providers follow the construction and purity contract of keyGenerator().
      Returns:
      the comparator class, or EqualityComparator.class for automatic selection.
      Default:
      arez.EqualityComparator.class
    • enhancer

      Class<?> enhancer
      Interface supplying fluent default methods for this input's builder step. The interface has one unbounded result type parameter and one abstract method matching the generated input setter's name and builder-facing value type. Its parameter nullness must be compatible with the input. Public default methods return the result parameter directly; they may declare method type parameters, varargs and checked exceptions.

      Inputs declared as ReactNode or its array type have builder setters accepting Renderable or its array type with the same nullness. Match those widened types in custom enhancers; supplied builders are materialized before storing the view input.

      The result is the next step, the current optional step, or ReactNode when setting the input finishes construction. First-step helpers also receive static shortcuts. Enhancers must coexist with all other methods and parent interfaces on the shared builder. Inputs sourced from tree context cannot specify an enhancer.

      void.class selects ChildrenEnhancer for a non-context input named children, and no enhancer for other inputs. An explicit interface replaces this default; it may extend ChildrenEnhancer to retain its helpers. Setting child or children always finishes construction, so their result parameter is ReactNode.

      Returns:
      the enhancer interface, or void.class for the default selection.
      Default:
      void.class
    • name

      String name
      Return the name of the input. The name is the key used when accessing the input from the inputs object. It is also used when creating the builder steps associated with inputs that are not sourced from tree context.
      Returns:
      the name of the input.
      Default:
      "<default>"
    • qualifier

      String qualifier
      Return the qualifier used to access value from context. It must only be specified if fromTreeContext() is set to true.
      Returns:
      the qualifier used to access value from context.
      Default:
      ""
    • fromTreeContext

      boolean fromTreeContext
      Return true if the input value should be sourced from tree context rather than supplied when creating the view. Inputs sourced from tree context are transparently passed from a parent view to descendant views and do not need to be specified by the user when creating the view.
      Returns:
      true if the input value should be sourced from tree context.
      Default:
      false
    • require

      Feature require
      Setting indicating whether the input should be supplied when the view is constructed. This influences validation when enabled and how the Builder class is created. If set to Feature.ENABLE then the user MUST supply the input and the builder will require the user to specify the value. If set to Feature.DISABLE then the user can optionally supply the input. If set to Feature.AUTODETECT then the annotation processor will treat it as Feature.DISABLE if the input is nullable, has a corresponding InputDefault, or fromTreeContext() is true; otherwise it is treated as Feature.ENABLE. A required nullable input still requires a builder call and permits a null value. An optional non-null reference input requires a non-null default or a tree-context source. Parametric nullness requires explicit requiredness or a valid default. The value of this setting must not be Feature.ENABLE when fromTreeContext() is true.
      Returns:
      the flag indicating whether the input needs to be supplied.
      Default:
      AUTODETECT
    • observable

      Feature observable
      Indicate whether the input should be annotated by Observable.

      If set to Feature.AUTODETECT then the input will be observable if and only if:

      • the input is not immutable.
      • the view has at least one method annotated with Memoize or Observe.
      Returns:
      the enum indicating whether input is observable.
      Default:
      AUTODETECT