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

arez.annotations.Memoize 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;

/**
 * Methods marked with this annotation are memoized while there is an observer.
 *
 * 

The return value should be derived from the parameters and any other Observables or ComputedValues * within the Arez system. The value returned by the method should not change unless the parameters or the * state of the other {@link Observable}s change. The method is wrapped in a READ_ONLY transaction and * thus can not modify other state in the system.

* *

This is implemented by creating a separate ComputedValue instance for each unique combination of * parameters. When the ComputedValue is deactivated, a hook triggers that removes the ComputedValue * from the local cache.

* *

The method that is annotated with @Memoize must comply with the additional constraints:

*
    *
  • Must not be annotated with any other arez annotation
  • *
  • Must have 1 or more parameters
  • *
  • Must return a value
  • *
  • Must not be private
  • *
  • Must not be static
  • *
  • Must not be final
  • *
  • Must not be abstract
  • *
  • Must not throw exceptions
  • *
*/ @Documented @Target( ElementType.METHOD ) public @interface Memoize { /** * Return the root name of the Memoized value relative to the component. This * will be used in combination with a sequence when naming the synthesized * ComputedValue instances. 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 root name of the Memoized value relative to the component. */ @Nonnull String name() default ""; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy