arez.annotations.ComponentStateRef Maven / Gradle / Ivy
package arez.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import javax.annotation.Nonnull;
/**
* Annotate the method that will be overridden to return true if the component is in the specified state.
* This is useful when the component must validate methods are only called in certain states or to change
* behaviour based on state (i.e. Avoid causing side-effects when disposing).
*
* The method that is annotated with this component must comply with the constraints:
*
* - May appear zero or more times on a component
* - Must not be annotated with any other arez annotation
* - Must have 0 parameters
* - Must return a boolean
* - Must be abstract
* - Must not throw exceptions
* - Must be accessible to the class annotated by the {@link ArezComponent} annotation.
* -
* Should not be public as not expected to be invoked outside the component. A warning will be generated but can
* be suppressed by the {@link SuppressWarnings} or {@link SuppressArezWarnings} annotations with a key
* "Arez:PublicRefMethod". 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 {@link ArezComponent} annotation as the method is not
* expected to be invoked outside the component. A warning will be generated but can be suppressed by the
* {@link SuppressWarnings} or {@link SuppressArezWarnings} annotations with a key "Arez:ProtectedMethod".
*
*
*/
@Documented
@Target( ElementType.METHOD )
public @interface ComponentStateRef
{
/**
* Return the component state which will cause the annotated method to return true.
*
* @return the component state which will cause annotated method to return true.
*/
@Nonnull
State value() default State.READY;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy