arez.annotations.Dependency 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;
/**
* Methods marked with this annotation are dependencies of the component.
* THe component observes the dependency and if the dependency is disposed takes
* an action to cascade the dispose or null the property referencing dependency.
*
* The method that is annotated with @Dependency must comply with the additional constraints:
*
* - Must not be annotated with any other arez annotation except {@link Observable} or {@link Computed}
* - Must have 0 parameters
* - Must return a value
* - Must not be private
* - Must not be static
* - Must not be abstract
* - Must not throw exceptions
*
*/
@Documented
@Target( ElementType.METHOD )
public @interface Dependency
{
/**
* The action to take when dependency is disposed.
*/
enum Action
{
/**
* Remove the component.
*/
CASCADE,
/**
* Set the {@link Observable} property that holds dependency to null.
*/
SET_NULL
}
/**
* Return the action to take when the dependency is disposed.
* A {@link Action#CASCADE} value indicates that the component should be deleted, while a
* {@link Action#SET_NULL} value indicates that the observable field should be set to null.
* The {@link Action#SET_NULL} is only valid on {@link Observable} properties that have an
* associated setter and are not annotated with {@link javax.annotation.Nonnull}.
*
* @return the action to take when the dependency is disposed.
*/
@Nonnull
Action action() default Action.CASCADE;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy