Annotation Interface CascadeDispose


Methods and fields annotated by this annotation should be disposed when the component is disposed. The dispose occurs after the PreDispose method.

It should be noted that it is preferable for the field that defines the contained component 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 contained component 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 other than Reference or Observable
  • Must have 0 parameters
  • The type of the field must implement Disposable or must be annotated by ArezComponent
  • Must not be private
  • Must not be static
  • Must not be abstract unless the method is annotated with Reference or Observable in which case it MUST 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 not be private
  • Must not be static
  • The type of the field must implement Disposable or must be annotated by ArezComponent
  • The field must be accessible to the component subclass which means it must be protected or package access if it is in the same package as the arez component.