Annotation Interface Publish


@Documented @Target(METHOD) public @interface Publish
Annotation to mark a method that returns a value to be published in context for child components. The value is published with the type that matches the return type of the method.

The method that is annotated with this annotation must also comply with the following constraints:

  • Must not be annotated with any other react annotation
  • Must have 0 parameters
  • Must return a value
  • Must not be private
  • Must not be abstract
  • Must not throw exceptions
  • Must be accessible from the same package as the class annotated by View
  • Should not be public as not expected to be invoked outside the view. A warning will be generated but can be suppressed by the SuppressWarnings or SuppressReact4jWarnings annotations with a key "React4j:PublicMethod". This warning is also suppressed by the annotation processor if it is implementing an interface method.
  • Should not be protected if in the class annotated with the View annotation as the method is not expected to be invoked outside the view. A warning will be generated but can be suppressed by the SuppressWarnings or SuppressReact4jWarnings annotations with a key "React4j:ProtectedMethod".
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Return the qualifier used to publish value to the context.
  • Element Details

    • qualifier

      @Nonnull String qualifier
      Return the qualifier used to publish value to the context.
      Returns:
      the qualifier used to publish value to the context.
      Default:
      ""