All Downloads are FREE. Search and download functionalities are using the official Maven repository.

arez.annotations.Observable Maven / Gradle / Ivy

There is a newer version: 0.95
Show newest version
package arez.annotations;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import javax.annotation.Nonnull;

/**
 * Annotation applied to methods that expose an Observable value in Arez.
 * Methods annotated with this either query state or mutate state. The query
 * method is expected to have 0 parameters and return a value and by default
 * is named with "get" or "is" prefixed to the property name. The mutation
 * method is expected to have a single parameter and return no value and by
 * default is named with "set" prefixed to property name. The setter or getter
 * can also be named matching the property name without the prefix.
 *
 * 

Only one of the query or mutation method needs to be annotated with * this annotation if the other method follows the normal conventions. If * the other method does not conform to conventions, then you will need to * annotate the pair and specify a value for {@link #name()}.

* *

The method should only invoked within the scope of a transaction. * The mutation method requires that the transaction be READ_WRITE.

* *

The method that is annotated with @Observable must also comply with the following constraints:

*
    *
  • Must not be annotated with any other arez annotation
  • *
  • Must not be private
  • *
  • Must not be static
  • *
  • Must not be final
  • *
  • May be abstract but if abstract then the paired setter or getter must also be abstract
  • *
*/ @Documented @Target( ElementType.METHOD ) public @interface Observable { /** * Return the name of the Observable relative to the component. If not specified * will default to the name of the property by convention as described above. * The value must conform to the requirements of a java identifier. * The name must also be unique across {@link Observable}s, * {@link Computed}s and {@link Action}s within the scope of the * {@link ArezComponent} annotated element. * * @return the name of the Observable relative to the component. */ @Nonnull String name() default ""; /** * Set this to false if there is no setter method and the component is * expected to use {@link ObservableRef} to indicate when value has changed. * * @return true if there is expected to be a setter, false if there should be no setter. */ boolean expectSetter() default true; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy