Annotation Interface MemoizeContextParameter
Memoize
annotated methods. A "contextual" parameter is one that is used within the Memoize
annotated methods,
but is not passed in but derived from the calling context. These are the conceptual equivalent of thread-local
values accessed from within the function.
There are expected to be a three methods for each context parameter: one to get the value from the calling context (optionally prefixed with "capture" that returns the type of the context parameter), one to push the value to the calling context (prefixed with "push" with a single parameter that has the type of the context parameter), and one to pop the value from the calling context (prefixed with "pop" with a single parameter that has the type of the context parameter).
Capture Method
The method to capture the context parameter is invoked prior to the invocation of the Memoize
annotated method when non-arez-framework code invokes the method. It may be invoked outside of an arez
transaction if the associated method has Memoize.readOutsideTransaction()
resolve to
Feature.DISABLE
. The method must also comply with the following additional constraints:
- Must not be annotated with any other arez annotation
- Must return a value
- Must not have any parameters
- Must not specify type parameters
- Must not be private
- Must not be static
- Must not be abstract
- Must not throw exceptions
- Must be accessible to the class annotated by the
ArezComponent
annotation.
Push Method
The method to push the context parameter into the current context is invoked prior to the invocation
of the Memoize
annotated method when the arez framework invokes the method to determine whether
the result has changed. It is invoked outside of an arez transaction. The method must also comply
with the following additional constraints:
The method that is annotated with this annotation must comply with the additional constraints:
- The method name must start with "push"
- Must not be annotated with any other arez annotation
- Must not return a value
- Must have one parameter
- Must not specify type parameters
- Must not be private
- Must not be static
- Must not be abstract
- Must not throw exceptions
- Must be accessible to the class annotated by the
ArezComponent
annotation.
Pop Method
The method to pop the context parameter from the current context is invoked after to the invocation
of the Memoize
annotated method when the arez framework invokes the method to determine whether
the result has changed. It is invoked outside of an arez transaction. The method must also comply
with the following additional constraints:
The method that is annotated with this annotation must comply with the additional constraints:
- The method name must start with "pop"
- Must not be annotated with any other arez annotation
- Must not return a value
- Must have one parameter
- Must not specify type parameters
- Must not be private
- Must not be static
- Must not be abstract
- Must not throw exceptions
- Must be accessible to the class annotated by the
ArezComponent
annotation.
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
Return true if the component does not need to haveMemoize
annotated methods match.Return the name of the context parameter.Return a regular expression for matching the arez names of memoized methods where this context parameter is tracked.
-
Element Details
-
name
Return the name of the context parameter. If not specified, then the name will be derived from the name of the method.- To derive the name from a push method then remove the "push" prefix.
- To derive the name from a pop method then remove the "pop" prefix.
- To derive the name from a capture method then remove the optional "capture" prefix else just use the method name if no such prefix.
- Returns:
- the name of the context parameter.
- Default:
- "<default>"
-
pattern
Return a regular expression for matching the arez names of memoized methods where this context parameter is tracked.- Returns:
- a regular expression for matching arez name of memoized methods.
- Default:
- ".*"
-
allowEmpty
boolean allowEmptyReturn true if the component does not need to haveMemoize
annotated methods match. Otherwise, if noMemoize
annotated methods match thepattern()
then the annotation processor will generate an error.- Returns:
- true if the memoized methods must match annotation, false otherwise.
- Default:
- false
-