001package arez.annotations;
002
003import java.lang.annotation.Documented;
004import java.lang.annotation.ElementType;
005import java.lang.annotation.Target;
006
007/**
008 * Methods and fields annotated by this annotation should be disposed when the component is disposed.
009 * The dispose occurs after the {@link PreDispose} method.
010 *
011 * <p>It should be noted that it is preferable for the field that defines the contained component is marked
012 * with this annotation rather than the method accessor. The reason is that the annotation processor
013 * will issue a warning if a field that the processor identifies as a potential contained component if it is
014 * not annotated with {@link ComponentDependency} or {@link CascadeDispose}.</p>
015 *
016 * <p>If the element annotated is a method then the method must comply with the additional constraints:</p>
017 * <ul>
018 * <li>Must not be annotated with any other arez annotation other than {@link Reference} or {@link Observable}</li>
019 * <li>Must have 0 parameters</li>
020 * <li>The type of the field must implement {@link arez.Disposable} or must be annotated by {@link ArezComponent}</li>
021 * <li>Must not be private</li>
022 * <li>Must not be static</li>
023 * <li>Must not be abstract unless the method is annotated with {@link Reference} or {@link Observable} in which case it MUST be abstract</li>
024 * <li>Must not throw exceptions</li>
025 * <li>Must be accessible to the class annotated by the {@link ArezComponent} annotation.</li>
026 * </ul>
027 *
028 * <p>If the element annotated is a field then the field must comply with the additional constraints:</p>
029 * <ul>
030 * <li>Must not be private</li>
031 * <li>Must not be static</li>
032 * <li>The type of the field must implement {@link arez.Disposable} or must be annotated by {@link ArezComponent}</li>
033 * <li>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.</li>
034 * </ul>
035 */
036@Documented
037@Target( { ElementType.METHOD, ElementType.FIELD } )
038public @interface CascadeDispose
039{
040}