Package react4j.annotations
Annotation 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
orSuppressReact4jWarnings
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 theSuppressWarnings
orSuppressReact4jWarnings
annotations with a key "React4j:ProtectedMethod".
-
Nested Class Summary
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionReturn 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 byObservable
.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
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 setsource()
toInput.Source.DEFAULT
.- Returns:
- the name of the input.
- Default:
- "<default>"
-
qualifier
Return the qualifier used to access value from context. It must only be specified ifsource()
is set toInput.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 toInput.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 toFeature.ENABLE
then the user MUST supply the input and the builder will require the user to specify the value. If set toFeature.DISABLE
then the user can optionally supply the input. If set toFeature.AUTODETECT
then the annotation processor will treat it asFeature.DISABLE
if there is a correspondingInputDefault
for the input or thesource()
parameter is set toInput.Source.CONTEXT
, otherwise it will be treated asFeature.ENABLE
. The value of this setting must not beFeature.ENABLE
whensource()
is set toInput.Source.CONTEXT
.- Returns:
- the flag indicating whether the input needs to be supplied.
- Default:
- AUTODETECT
-
observable
Indicate whether the input should be annotated byObservable
.If set to
Feature.AUTODETECT
then the input will be observable if and only if:immutable()
()} is not set totrue
.- the view has at least one method annotated with
Memoize
orObserve
.
- 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 toFeature.AUTODETECT
then the annotation processor will inspect the type of the input and treat it asFeature.ENABLE
if the type is annotated with theArezComponent
annotation or theActAsComponent
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 setimmutable()
totrue
,disposable()
MUST resolve toFeature.ENABLE
. The type of the input is expected to implement theDisposeNotifier
interface either directly or indirectly. If this parameter is set toFeature.AUTODETECT
then the annotation processor will treat it asFeature.ENABLE
ifimmutable()
istrue
anddisposable()
resolves toFeature.ENABLE
.- Returns:
- an enum indicating whether the view should be disposed if the input is disposed.
- Default:
- AUTODETECT
-
immutable
boolean immutableTrue 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 theArezComponent.requireId()
parameter does not resolve toFeature.DISABLE
- any class or interface that is annotated with
ActAsComponent
. It is assumed that every implementation is an Arez component where theArezComponent.requireId()
parameter does not resolve toFeature.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 theIdentifiable
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 eitherArezComponent
orActAsComponent
then the annotation processor will assume theKeyed
interface is to used in preference to other alternative strategies.- Returns:
- true if changing the input recreates the view.
- Default:
- false
- primitive types (i.e. boolean, short etc) and their corresponding boxed types (i.e.
-