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 * Annotation applied to a static field or static method that supplies the initial value for an 010 * {@link Observable} property. 011 * 012 * <p>The annotation should be paired with an abstract {@link Observable} property on the same component. 013 * The annotated element must be a static, final field or a static method. The initial value will be used 014 * when constructing the generated component and removes the need to pass the value via the constructor.</p> 015 * 016 * <p>If the associated {@link Observable} getter is annotated with {@link Nonnull} then 017 * the annotated field or method should also be annotated with {@link Nonnull}.</p> 018 * 019 * <p>This annotation is only supported on elements contained within a type annotated by 020 * {@link ArezComponent} or {@link ArezComponentLike}. Other usages will fail compilation.</p> 021 */ 022@Documented 023@Target( { ElementType.METHOD, ElementType.FIELD } ) 024public @interface ObservableInitial 025{ 026 /** 027 * Return the name of the associated Observable. 028 * 029 * <p>If the annotation is applied to a method, this value will be derived if the method name matches 030 * the pattern "getInitial[Name]", otherwise it must be specified.</p> 031 * 032 * <p>If the annotation is applied to a field, this value will be derived if the field name matches 033 * the pattern "INITIAL_[NAME]", otherwise it must be specified.</p> 034 * 035 * @return the name of the Observable. 036 */ 037 @Nonnull 038 String name() default "<default>"; 039}