Annotation Interface ImpureFunction


@Retention(RUNTIME) @Target({CONSTRUCTOR,FIELD,METHOD}) public @interface ImpureFunction
Impure function annotation.

This annotation can be used to state that a constructor or a method is an impure function. An impure function is the opposite of a pure function.

An impure function may have the following characteristics that are listed in the ImpurityKind enum:

  • retains or returns a reference to a mutable value (HOLD_PARAMETER)
  • has a side effect (SIDE_EFFECT)
  • depends on a external state (EXTERNAL). Members that depend on external state are most unwelcome in rule conditions.

All those characteristics may be combined in the same member (ANY).

  • Element Details

    • kind

      Default:
      ANY
    • modifyThis

      boolean modifyThis
      Returns:
      true if the method changes this (or the class in the case of a static method)
      Default:
      true
    • modifyParameters

      int modifyParameters
      Returns:
      Indexes of the modified parameters as bits By default, all parameters are considered as modified. When no parameters are modified, use 0 For each modified parameter, set the corresponding bit to 1; E.g. for a method that modifies the first parameter, it should be set to 0b1 or 1 E.g. for a method that modifies the first and third parameter, it should be set to 0b101, or 5
      Default:
      255