Annotation 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".
  • Should be annotated with either Nonnull or Nullable if the return type is not a primitive. A warning will be generated but can be suppressed by the SuppressWarnings or SuppressReact4jWarnings annotations with a key "React4j:MissingInputNullability".
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Return true if the input value should be sourced from tree context rather than supplied when creating the view.
    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

    • name

      @Nonnull 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

      @Nonnull 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

      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

      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 there is a corresponding InputDefault for the input or fromTreeContext() is true, otherwise it will be treated as Feature.ENABLE. 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

      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