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@Documented
020@Target( { ElementType.METHOD, ElementType.FIELD } )
021public @interface ObservableInitial
022{
023  /**
024   * Return the name of the associated Observable.
025   *
026   * <p>If the annotation is applied to a method, this value will be derived if the method name matches
027   * the pattern "getInitial[Name]", otherwise it must be specified.</p>
028   *
029   * <p>If the annotation is applied to a field, this value will be derived if the field name matches
030   * the pattern "INITIAL_[NAME]", otherwise it must be specified.</p>
031   *
032   * @return the name of the Observable.
033   */
034  @Nonnull
035  String name() default "<default>";
036}