001package react4j.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 used to specify the default value for a input.
010 * The annotation can be applied to a static field or static method on the view.
011 * The field or method is then accessed when initializing the default inputs for the view.
012 *
013 * <p>If a method is annotated with this annotation then it must also comply with the following constraints:</p>
014 * <ul>
015 * <li>Must have 0 parameters</li>
016 * <li>Must return a value with the same type as the associated {@link Input @Input} annotated method</li>
017 * <li>Must be a static method</li>
018 * <li>Must not be private</li>
019 * <li>Must not throw exceptions</li>
020 * </ul>
021 *
022 * <p>If a field is annotated with this annotation then it must also comply with the following constraints:</p>
023 * <ul>
024 * <li>Must have the same type as the associated {@link Input @Input} annotated method</li>
025 * <li>Must be a static field</li>
026 * <li>Must be a final field</li>
027 * <li>Must not be private</li>
028 * <li>Must be accessible from the same package as the class annotated by {@link View}</li>
029 * </ul>
030 */
031@Documented
032@Target( { ElementType.METHOD, ElementType.FIELD } )
033public @interface InputDefault
034{
035  /**
036   * Return the name of the associated input.
037   *
038   * <p>If the annotation is applied to a method, this value will be derived if the method name matches
039   * the pattern "get[Name]Default", otherwise it must be specified.</p>
040   *
041   * <p>If the annotation is applied to a field, this value will be derived if the field name matches
042   * the pattern "DEFAULT_[NAME]", otherwise it must be specified.</p>
043   *
044   * @return the name of the input.
045   */
046  @Nonnull
047  String name() default "<default>";
048}