Package arez.annotations
Annotation Interface ComponentDependency
Methods and fields marked with this annotation are dependencies of the component.
If the dependency is disposed then the component takes an action to cascade the dispose
or null the property referencing the dependency. The dependency MUST implement the
DisposeNotifier
interface.
It should be noted that it is preferable for the field that defines the dependency is marked
with this annotation rather than the method accessor. The reason is that the annotation processor
will issue a warning if a field that the processor identifies as a potential dependency if it is
not annotated with ComponentDependency
or CascadeDispose
.
If the element annotated is a method then the method must comply with the additional constraints:
- Must not be annotated with any other arez annotation except
Observable
- If not annotated with
Observable
then must be final - Must have 0 parameters
-
Must return a value that implements
DisposeNotifier
or is annotated withArezComponent
. This will be checked at compile-time unlessvalidateTypeAtRuntime()
set totrue
. - Must not be private
- Must not be static
- If not annotated with
Observable
then must not be abstract - Must not throw exceptions
- Must be accessible to the class annotated by the
ArezComponent
annotation.
If the element annotated is a field then the field must comply with the additional constraints:
- Must be final
- Must be a type that implements
DisposeNotifier
or is annotated withArezComponent
- Must not be private
- Must not be static
- Must be accessible to the class annotated by the
ArezComponent
annotation.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The action to take when dependency is disposed. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionReturn the action to take when the dependency is disposed.boolean
Return true and the value of the annotated field will be validated at runtime rather than at compile time.
-
Element Details
-
action
Return the action to take when the dependency is disposed. AComponentDependency.Action.CASCADE
value indicates that the component should be deleted, while aComponentDependency.Action.SET_NULL
value indicates that the observable field should be set to null. TheComponentDependency.Action.SET_NULL
is only valid onObservable
properties that have an associated setter and are not annotated withNonnull
.- Returns:
- the action to take when the dependency is disposed.
- Default:
- CASCADE
-
validateTypeAtRuntime
boolean validateTypeAtRuntimeReturn true and the value of the annotated field will be validated at runtime rather than at compile time. This is useful when the field is defined by an interface but the underlying field is guaranteed to implementDisposeNotifier
at runtime.- Returns:
- true to defer validation of types until runtime.
- Default:
- false
-