001package arez.annotations; 002 003import java.lang.annotation.Documented; 004import java.lang.annotation.ElementType; 005import java.lang.annotation.Target; 006 007/** 008 * Annotate the method that should return the Id for Arez component. 009 * 010 * <p>This annotation should appear at most once on a component. The 011 * annotation should be on a method that accepts no parameters and returns 012 * a non-null value.</p> 013 * 014 * <p>If this annotation is present, it indicates that the Annotation processor 015 * should call this method to get the ID of the component. This ID should be 016 * constant and unique (enough) to identify the component. It is used when generating 017 * debug names for observables nested within the component. It is also used as the id 018 * under which an component is stored when repositories are being generated. If this 019 * annotation is not present the Annotation processor will synthesize an ID as a 020 * monotonically increasing integer for each instance of the type.</p> 021 * 022 * <p>It should also be noted that this method will be invoked before the component 023 * has been completely constructed as it is used during construction of the reactive 024 * elements.</p> 025 * 026 * <p>The method that is annotated with this annotation must comply with the additional constraints:</p> 027 * <ul> 028 * <li>Must not be annotated with any other arez annotation</li> 029 * <li>Must have 0 parameters</li> 030 * <li>Must return a value</li> 031 * <li>Must not be private</li> 032 * <li>Must not be static</li> 033 * <li>Must not be abstract</li> 034 * <li>Must not throw exceptions</li> 035 * <li>Must be accessible to the class annotated by the {@link ArezComponent} annotation.</li> 036 * </ul> 037 */ 038@Documented 039@Target( ElementType.METHOD ) 040public @interface ComponentId 041{ 042}