Impure functions
The
@ImpureFunction annotation is used to mark methods and constructors
as impure.
Functions that are not pure are considered impure. Impure functions can be called in the rule actions.
Impure functions can have the following characteristics:
- Have a side effect.
- Store or return a reference to a mutable value.
- Depend on external state, such as the system clock.
These characteristics are listed in an @ImpurityKind enumeration.
Some methods that are considered impure do not need the @ImpureFunction
annotation because they follow a specific naming convention. That is the case of the setter, adder,
remover, and clearer methods. For more information about these methods, see Method restrictions.