Annotation Interface Input
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
SuppressWarningsorSuppressReact4jWarningsannotations 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
Viewannotation as the method is not expected to be invoked outside the view. A warning will be generated but can be suppressed by theSuppressWarningsorSuppressReact4jWarningsannotations with a key "React4j:ProtectedMethod". -
Nullness follows the declaring JSpecify scope. Use
Nullablefor nullable input values, or declare aNullMarkedscope for non-null defaults. Legacy nullability annotations are ignored.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?> 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.booleanReturntrueif the input value should be sourced from tree context rather than supplied when creating the view.Class<?> Provider of this immutable constructor input's key contribution.Return the name of the input.Indicate whether the input should be annotated byObservable.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<?> keyGeneratorProvider of this immutable constructor input's key contribution. The provider implementsInputKeyGeneratorfor 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.classuses automatic derivation.- Returns:
- the key provider class.
- Default:
void.class
-
equalityComparator
Class<? extends arez.EqualityComparator> equalityComparatorComparator defining changes to this mutable method input, including rendering, Arez invalidation and input-change callbacks. An explicit comparator overrides the exact declared type'sDefaultEqualityComparator. Without either selection, JavaScript strict equality is used. Providers follow the construction and purity contract ofkeyGenerator().- Returns:
- the comparator class, or
EqualityComparator.classfor automatic selection.
- Default:
arez.EqualityComparator.class
-
enhancer
Class<?> enhancerInterface 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
ReactNodeor its array type have builder setters acceptingRenderableor 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
ReactNodewhen 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.classselectsChildrenEnhancerfor a non-context input namedchildren, and no enhancer for other inputs. An explicit interface replaces this default; it may extendChildrenEnhancerto retain its helpers. Settingchildorchildrenalways finishes construction, so their result parameter isReactNode.- Returns:
- the enhancer interface, or
void.classfor the default selection.
- Default:
void.class
-
name
String nameReturn 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 qualifierReturn the qualifier used to access value from context. It must only be specified iffromTreeContext()is set totrue.- Returns:
- the qualifier used to access value from context.
- Default:
""
-
fromTreeContext
boolean fromTreeContextReturntrueif 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:
trueif the input value should be sourced from tree context.
- Default:
false
-
require
Feature requireSetting 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 toFeature.ENABLEthen the user MUST supply the input and the builder will require the user to specify the value. If set toFeature.DISABLEthen the user can optionally supply the input. If set toFeature.AUTODETECTthen the annotation processor will treat it asFeature.DISABLEif the input is nullable, has a correspondingInputDefault, orfromTreeContext()istrue; otherwise it is treated asFeature.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 beFeature.ENABLEwhenfromTreeContext()istrue.- Returns:
- the flag indicating whether the input needs to be supplied.
- Default:
AUTODETECT
-
observable
Feature observableIndicate whether the input should be annotated byObservable.If set to
Feature.AUTODETECTthen the input will be observable if and only if:- the input is not immutable.
- the view has at least one method annotated with
MemoizeorObserve.
- Returns:
- the enum indicating whether input is observable.
- Default:
AUTODETECT
-