Annotation Interface ArezComponent


Annotation that marks classes or interfaces to be processed by Arez annotation processor. Classes or interfaces with this annotation can contain 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 class com.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 or Observable

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.

  • Element Details

    • name

      @Nonnull String 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 allowEmpty
      Return true if the component does not need to explicitly declare elements. Otherwise if no elements (i.e. Observables, Actions, Observes 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 annotations sting.Named, sting.Typed and sting.Eager or the jsr330 annotation javax.inject.Named or any annotation that is annotated with javax.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 the ComponentObservable interface and allowing invocation of the ComponentObservable.observe(Object) method. If unset or explicitly set to Feature.AUTODETECT then the component will implement the interface if the disposeOnDeactivate() parameter is true.
      Returns:
      enum to control whether the component should support being "observed".
      Default:
      AUTODETECT
    • disposeNotifier

      Return enum to control whether the component should support implement the DisposeNotifier 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 the DisposeNotifier interface is not implemented if the service() resolves to Feature.ENABLE.

      Returns:
      Return enum to control whether the component should implement DisposeNotifier.
      Default:
      AUTODETECT
    • disposeOnDeactivate

      Return true if the component should dispose itself once it is no longer "observed". By "observed" it means that the component will have ComponentObservable.observe(Object) called on it. This parameter MUST be false if observable() has the value Feature.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 is Feature.AUTODETECT then sting integration will be enabled if the service() resolves to Feature.ENABLE and the sting.Injector class is present on the classpath.
      Returns:
      an enum controlling whether a sting integration is enabled.
      Default:
      AUTODETECT
    • requireEquals

      Indicate whether the Object.hashCode() and Object.equals(Object) methods need to be implemented. If set to Feature.AUTODETECT then the methods will not be generated.
      Returns:
      an enum whether the Object.hashCode() and Object.equals(Object) methods need to be implemented.
      Default:
      AUTODETECT
    • requireId

      Indicates whether the component should support access of the id via Identifiable.getArezId(Object). The Feature.AUTODETECT will be treated as Feature.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
    • verify

      Indicates whether the component should implement the interface Verifiable. This feature is ignored unless Arez.isVerifyEnabled() is true. The Feature.AUTODETECT value will enable this feature if the component has any Reference methods or any Inverse 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 with CascadeDispose or ComponentDependency. 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 the disposeNotifier() resolves to Feature.ENABLE.
      Returns:
      enum controlling whether a references to components should be explicitly managed.
      Default:
      AUTODETECT
    • defaultPriority

      The default priority used by Memoize and Observe annotated methods. This parameter should only be specified if there are Memoize or Observe annotated methods present on the component.
      Returns:
      the default priority used by Memoize and Observe annotated methods.
      Default:
      NORMAL
    • defaultReadOutsideTransaction

      The default value for the readOutsideTransaction parameter of Memoize and Observable 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 of Observable 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