react4j.annotations.Prop Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of react4j-annotations Show documentation
Show all versions of react4j-annotations Show documentation
Annotations for defining a react component
package react4j.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import javax.annotation.Nonnull;
/**
* Annotation used to specify an abstract method that returns a prop.
* The property is extracted from Reacts underlying props object.
*
* The method that is annotated with @Prop
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 be an abstract instance method
* - Must not throw exceptions
* - Must be accessible from the same package as the class annotated by {@link ReactComponent}
*
*/
@Documented
@Target( ElementType.METHOD )
public @interface Prop
{
/**
* Return the name of the prop.
* If the underlying method conforms to java beans accessor conventions (i.e. starts with "is" and is a boolean
* or starts with "get") then the name is the same as the java bean convention dictates, otherwise the name of
* the method is used as the default value for the prop.
*
* @return the name of the prop.
*/
@Nonnull
String name() default "";
/**
* Return enum indicating whether prop should be when component is constructed.
* This influences validation when enabled and how the Builder class is created.
* If set to {@link Feature#ENABLE} then the user MUST supply the prop and the builder will require the user
* to specify the value. If set to {@link Feature#DISABLE} then the user can optionally supply the prop.
* If set to {@link Feature#AUTODETECT} then the annotation processor will treat it as {@link Feature#DISABLE}
* if theere is a corresponding {@link PropDefault} for the prop, otherwise it will be treated as
* {@link Feature#ENABLE}.
*
* @return the flag indicating whether the prop needs to be supplied.
*/
Feature require() default Feature.AUTODETECT;
}