@Documented
@Target(value=METHOD)
public @interface Prop
The method that is annotated with this annotation must also comply with the following constraints:
ReactComponent
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.
ReactComponent
annotation as the method is not
expected to be invoked outside the component. A warning will be generated but can be suppressed by the
SuppressWarnings
or SuppressReact4jWarnings
annotations with a key "React4j:ProtectedMethod".
Modifier and Type | Optional Element and Description |
---|---|
Feature |
disposable
Return an enum indicating whether the component should check whether the value of the prop is disposed
prior to rendering.
|
boolean |
immutable
True if the prop is not expected to change after initial value is set.
|
java.lang.String |
name
Return the name of the prop.
|
Feature |
observable
Indicate whether the prop should be annotated by
Observable . |
java.lang.String |
qualifier
Return the qualifier used to access value from context.
|
Feature |
require
Setting indicating whether the prop should be supplied when the component is constructed.
|
Feature |
shouldUpdateOnChange
Indicate whether changing the value of the prop should schedule a re-render.
|
Prop.Source |
source
The setting controlling where the prop value is source from.
|
@Nonnull public abstract java.lang.String name
source()
to Prop.Source.DEFAULT
.@Nonnull public abstract java.lang.String qualifier
source()
is set to Prop.Source.CONTEXT
.public abstract Prop.Source source
public abstract Feature require
Feature.ENABLE
then the user MUST supply the prop and the builder will require the user
to specify the value. If set to Feature.DISABLE
then the user can optionally supply the prop.
If set to Feature.AUTODETECT
then the annotation processor will treat it as Feature.DISABLE
if there is a corresponding PropDefault
for the prop or the source()
parameter is set to
Prop.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 Prop.Source.CONTEXT
.public abstract Feature shouldUpdateOnChange
Feature.AUTODETECT
then the annotation processor will treat it as
Feature.ENABLE
unless immutable()
is set to true
.public abstract Feature observable
Observable
.
If set to Feature.AUTODETECT
then the prop will be observable if and only if:
shouldUpdateOnChange()
is not set to Feature.DISABLE
.Memoize
or Observe
.public abstract Feature disposable
Feature.AUTODETECT
then the annotation processor will inspect the
type of the prop and treat it as Feature.ENABLE
if the type is annotated with the ArezComponent
annotation or the ActAsComponent
annotation.public abstract boolean immutable
Boolean
, Short
etc).String
typeKeyed
ArezComponent
where the ArezComponent.requireId()
parameter does not resolve to Feature.DISABLE
ActAsComponent
. It is assumed that every implementation is an Arez component where the ArezComponent.requireId()
parameter does not resolve to Feature.DISABLE
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.
In the future, the annotation processor may include additional allowable types such as those that implement
Identifiable
directly or other primitive types within the runtime library. These other
types will be added if demand is established, othewise an additional hook will be added to allow users to
customize key generation using a static method on the component.