Annotation Interface Input


@Documented @Target(METHOD) public @interface Input
Annotation used to specify an abstract method that returns a prop. The property is extracted from Reacts underlying props object. By default the prop is passed as a value in when creating the view but it can also be retrieved from the react context.

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".
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enum where the input is sourced from.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Return an enum indicating whether the view should be disposed if the input is disposed.
    Return an enum indicating whether the view should check whether the value of the input is disposed prior to rendering.
    boolean
    True if the input is not expected to change after initial value is set.
    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.
    The setting controlling where the input value is source from.
  • 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 the inputs that set source() to Input.Source.DEFAULT.
      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 source() is set to Input.Source.CONTEXT.
      Returns:
      the qualifier used to access value from context.
      Default:
      ""
    • source

      The setting controlling where the input value is source from. If the source is set to Input.Source.CONTEXT then the input is sometimes described as a "TreeInput" as it is transparently passed from a parent view to all child views. A "TreeInput" does not have to be specified by the user when creating the view.
      Returns:
      the setting controlling where the input value is source from.
      Default:
      DEFAULT
    • 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 the source() parameter is set to Input.Source.CONTEXT, otherwise it will be treated as Feature.ENABLE. The value of this setting must not be Feature.ENABLE when source() is set to Input.Source.CONTEXT.
      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:

      Returns:
      the enum indicating whether input is observable.
      Default:
      AUTODETECT
    • disposable

      Return an enum indicating whether the view should check whether the value of the input is disposed prior to rendering. If the value is disposed then the render method will exit early and return null. If this parameter is set to Feature.AUTODETECT then the annotation processor will inspect the type of the input and treat it as Feature.ENABLE if the type is annotated with the ArezComponent annotation or the ActAsComponent annotation.
      Returns:
      an enum indicating whether the view should check whether the value of the input is disposed prior to rendering.
      Default:
      AUTODETECT
    • dependency

      Return an enum indicating whether the view should be disposed if the input is disposed. To enable this feature, the input MUST set immutable() to true, disposable() MUST resolve to Feature.ENABLE. The type of the input is expected to implement the DisposeNotifier interface either directly or indirectly. If this parameter is set to Feature.AUTODETECT then the annotation processor will treat it as Feature.ENABLE if immutable() is true and disposable() resolves to Feature.ENABLE.
      Returns:
      an enum indicating whether the view should be disposed if the input is disposed.
      Default:
      AUTODETECT
    • immutable

      boolean immutable
      True if the input is not expected to change after initial value is set. If the value of the input does change then it is expected that the view will be unmounted and a new view created. This is implemented by synthesizing a key for the view every time the view that is derived from this input. To enable this the annotation processor must be able to identify the type of the input so that a key can be synthesized. The following types are supported by the annotation processor;
      • primitive types (i.e. boolean, short etc) and their corresponding boxed types (i.e. Boolean, Short etc).
      • the String type
      • any class that implements Keyed
      • any class that is annotated with ArezComponent where the ArezComponent.requireId() parameter does not resolve to Feature.DISABLE
      • any class or interface that is annotated with ActAsComponent. It is assumed that every implementation is an Arez component where the ArezComponent.requireId() parameter does not resolve to Feature.DISABLE
      • any class or interface that is compatible with Identifiable
      • if none of the above scenarios is valid then the code will attempt to derive the key at runtime. First via the Keyed interface, then the Identifiable interface and if these strategies are not possible then toString() will be invoked on the input.

      It should be noted that if a type implements Keyed and is annotated with either ArezComponent or ActAsComponent then the annotation processor will assume the Keyed interface is to used in preference to other alternative strategies.

      Returns:
      true if changing the input recreates the view.
      Default:
      false