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 to mark a method that returns a value to be published in context for child components.
010 * The value is published with the type that matches the return type of the method.
011 *
012 * <p>The method that is annotated with this annotation must also comply with the following constraints:</p>
013 * <ul>
014 * <li>Must not be annotated with any other react annotation</li>
015 * <li>Must have 0 parameters</li>
016 * <li>Must return a value</li>
017 * <li>Must not be private</li>
018 * <li>Must not be abstract</li>
019 * <li>Must not throw exceptions</li>
020 * <li>Must be accessible from the same package as the class annotated by {@link View}</li>
021 * <li>
022 *   Should not be public as not expected to be invoked outside the view. A warning will be generated but can
023 *   be suppressed by the {@link SuppressWarnings} or {@link SuppressReact4jWarnings} annotations with a key
024 *   "React4j:PublicMethod". This warning is also suppressed by the annotation processor if it is implementing
025 *   an interface method.
026 * </li>
027 * <li>
028 *   Should not be protected if in the class annotated with the {@link View} annotation as the method is not
029 *   expected to be invoked outside the view. A warning will be generated but can be suppressed by the
030 *   {@link SuppressWarnings} or {@link SuppressReact4jWarnings} annotations with a key "React4j:ProtectedMethod".
031 * </li>
032 * </ul>
033 */
034@Documented
035@Target( ElementType.METHOD )
036public @interface Publish
037{
038  /**
039   * Return the qualifier used to publish value to the context.
040   *
041   * @return the qualifier used to publish value to the context.
042   */
043  @Nonnull
044  String qualifier() default "";
045}