Annotation Interface ArezComponent
Observable
properties,
Memoize
properties, Observe
methods and Action
methods.
The annotation controls the way that contained actions and observables are named (if names are enabled in the system.
- The value returned by
name()
indicates the type name for instances of this object. If not specified it will default to the SimpleName of the class. i.e. The classcom.biz.models.MyModel
will default to a name of "MyModel".
The name of any elements contained within the component follows the pattern
"[ArezComponent.name].[ArezComponent.id].[Element.name]
".
The type that is annotated with this annotation must comply with the additional constraints:
- Must be a class or an interface
- Must be abstract
- Must not be final
- Must not be a non-static nested class
- Must have at least one method annotated with
Action
,Observe
,Memoize
orObservable
The annotation processor that handles this annotation will analyze all super classes and super
interfaces. This includes analysis of default methods on interfaces. So it is perfectly valid to
add annotations such as Observable
, Memoize
, Action
, PreDispose
and/or
PostDispose
to default methods on implemented interfaces.
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
Return true if the component does not need to explicitly declare elements.The default value for the readOutsideTransaction parameter ofMemoize
andObservable
annotated methods.The default value for the writeOutsideTransaction parameter ofObservable
annotated methods.Return enum to control whether the component should support implement theDisposeNotifier
interface.boolean
Return true if the component should dispose itself once it is no longer "observed".Return the name of the type.The enum to control whether the component should support being "observed" by implementing theComponentObservable
interface and allowing invocation of theComponentObservable.observe(Object)
method.Indicate whether theObject.hashCode()
andObject.equals(Object)
methods need to be implemented.Indicates whether the component should support access of the id viaIdentifiable.getArezId(Object)
.An enum controlling whether the component is treated like a service or an entity.Enum controlling whether sting integration is enabled.Indicates whether the component should implement the interfaceVerifiable
.Indicate whether references to the component should also be annotated withCascadeDispose
orComponentDependency
.
-
Element Details
-
name
Return the name of the type. The value must conform to the requirements of a java identifier.- Returns:
- the name of the type.
- Default:
- "<default>"
-
allowEmpty
boolean allowEmptyReturn true if the component does not need to explicitly declare elements. Otherwise if no elements (i.e.Observable
s,Action
s,Observe
s etc) are defined on a component it will generate an error.- Returns:
- true if the component does not need to explicitly declare elements, false otherwise.
- Default:
- false
-
service
An enum controlling whether the component is treated like a service or an entity. A service is expected to be a long running component that exists based on the functionality of the application while an entity represents data within the application and may come and go based on changes in the application data. Within arez, the only practical effect is to change the default behaviour of other features. See the documentation for other parameters for further details.If set as
Feature.AUTODETECT
or left as the default value, then Arez will assumes that if the component is injected using dependency injection, then the component is a service. Arez detects whether the type is annotated by the sting annotationssting.Named
,sting.Typed
andsting.Eager
or the jsr330 annotationjavax.inject.Named
or any annotation that is annotated withjavax.inject.Scope
annotation. If such an annotation is found then the component defaults to being treated like a service.- Returns:
- an enum controlling whether the component is treated like a service or an entity.
- Default:
- AUTODETECT
-
observable
The enum to control whether the component should support being "observed" by implementing theComponentObservable
interface and allowing invocation of theComponentObservable.observe(Object)
method. If unset or explicitly set toFeature.AUTODETECT
then the component will implement the interface if thedisposeOnDeactivate()
parameter istrue
.- Returns:
- enum to control whether the component should support being "observed".
- Default:
- AUTODETECT
-
disposeNotifier
Return enum to control whether the component should support implement theDisposeNotifier
interface. This will result in the component invoking dispose listener callbacks during dispose operation within the scope of the disposing transaction.If the value of this parameter is
Feature.AUTODETECT
then theDisposeNotifier
interface is not implemented if theservice()
resolves toFeature.ENABLE
.- Returns:
- Return enum to control whether the component should implement DisposeNotifier.
- Default:
- AUTODETECT
-
disposeOnDeactivate
boolean disposeOnDeactivateReturn true if the component should dispose itself once it is no longer "observed". By "observed" it means that the component will haveComponentObservable.observe(Object)
called on it. This parameter MUST be false ifobservable()
has the valueFeature.DISABLE
.- Returns:
- true if the component should dispose itself once it is no longer "observed".
- Default:
- false
-
sting
Enum controlling whether sting integration is enabled. If enabled, the annotation processor will add sting annotations to the generated component implementation. If the value of this parameter isFeature.AUTODETECT
then sting integration will be enabled if theservice()
resolves toFeature.ENABLE
and thesting.Injector
class is present on the classpath.- Returns:
- an enum controlling whether a sting integration is enabled.
- Default:
- AUTODETECT
-
requireEquals
Indicate whether theObject.hashCode()
andObject.equals(Object)
methods need to be implemented. If set toFeature.AUTODETECT
then the methods will not be generated.- Returns:
- an enum whether the
Object.hashCode()
andObject.equals(Object)
methods need to be implemented.
- Default:
- AUTODETECT
-
requireId
Indicates whether the component should support access of the id viaIdentifiable.getArezId(Object)
. TheFeature.AUTODETECT
will be treated asFeature.ENABLE
. This feature must be enabled in the following scenarios:- a method annotated with the
Inverse
annotation is present. - a method annotated with the
ComponentId
annotation is present. - a method annotated with the
ComponentIdRef
annotation is present.
- Returns:
- enum controlling whether a unique if of the component can be accessed via
Identifiable.getArezId(Object)
.
- Default:
- AUTODETECT
- a method annotated with the
-
verify
Indicates whether the component should implement the interfaceVerifiable
. This feature is ignored unlessArez.isVerifyEnabled()
is true. TheFeature.AUTODETECT
value will enable this feature if the component has anyReference
methods or anyInverse
methods.- Returns:
- enum that indicates whether the component should implement the interface
Verifiable
.
- Default:
- AUTODETECT
-
verifyReferencesToComponent
Indicate whether references to the component should also be annotated withCascadeDispose
orComponentDependency
. This is used to ensure that when a component is disposed that any reference to the component from another component is rectified. The annotation processor will warn if the above rules are violated.Feature.ENABLE
will tell the annotation to warn if references to component are invalid.Feature.DISABLE
disables the warning.Feature.AUTODETECT
will enable the warning if thedisposeNotifier()
resolves toFeature.ENABLE
.- Returns:
- enum controlling whether a references to components should be explicitly managed.
- Default:
- AUTODETECT
-
defaultPriority
The default priority used byMemoize
andObserve
annotated methods. This parameter should only be specified if there areMemoize
orObserve
annotated methods present on the component.- Default:
- NORMAL
-
defaultReadOutsideTransaction
The default value for the readOutsideTransaction parameter ofMemoize
andObservable
annotated methods.- Returns:
- The flag indicating whether the default is to allow reads outside a transaction or to require a transaction to read observables and memoized values.
- Default:
- AUTODETECT
-
defaultWriteOutsideTransaction
The default value for the writeOutsideTransaction parameter ofObservable
annotated methods.- Returns:
- The flag indicating whether the default is to allow writes outside a transaction or to require a transaction to write observables values.
- Default:
- AUTODETECT
-