001package arez.annotations; 002 003import java.lang.annotation.Documented; 004import java.lang.annotation.ElementType; 005import java.lang.annotation.Target; 006import javax.annotation.Nonnull; 007 008/** 009 * Identifies method that is called when the {@link arez.ComputableValue} changes from the INACTIVE state to any other state. 010 * 011 * <p>This method can only be associated with a {@link Memoize} annotated method that has 0 parameters. 012 * This limitation is in place to limit implementation complexity and because no use case for this 013 * functionality has been found.</p> 014 * 015 * <p>The method must also conform to the following constraints:</p> 016 * <ul> 017 * <li>Must not be annotated with any other arez annotation</li> 018 * <li>Must have either 0 parameters or a single parameter of type {@link arez.ComputableValue}</li> 019 * <li>Must not return a value</li> 020 * <li>Must not be private</li> 021 * <li>Must not be static</li> 022 * <li>Must not be abstract</li> 023 * <li>Must not throw exceptions</li> 024 * <li>Must not be for a {@link Memoize} method that has the {@link Memoize#keepAlive} parameter set to true</li> 025 * <li>Must be accessible to the class annotated by the {@link ArezComponent} annotation.</li> 026 * <li> 027 * Should not be public as not expected to be invoked outside the component. A warning will be generated but can 028 * be suppressed by the {@link SuppressWarnings} or {@link SuppressArezWarnings} annotations with a key 029 * "Arez:PublicHookMethod". This warning is also suppressed by the annotation processor if it is implementing 030 * an interface method. 031 * </li> 032 * <li> 033 * Should not be protected if in the class annotated with the {@link ArezComponent} annotation as the method is not 034 * expected to be invoked outside the component. A warning will be generated but can be suppressed by the 035 * {@link SuppressWarnings} or {@link SuppressArezWarnings} annotations with a key "Arez:ProtectedMethod". 036 * </li> 037 * </ul> 038 */ 039@Documented 040@Target( ElementType.METHOD ) 041public @interface OnActivate 042{ 043 /** 044 * Return the name of the ComputableValue that this method is associated with. 045 * This value will be derived if the method name matches the pattern "on[Name]Activate", 046 * otherwise it must be specified. 047 * 048 * @return the name of the ComputableValue. 049 */ 050 @Nonnull 051 String name() default "<default>"; 052}