Package groovy.transform

# Annotation Interface Reducer

@Documented @Incubating @Target(METHOD) @Retention(RUNTIME) public @interface Reducer
Declares that a two-argument combining method is associative and has an identity element — together, the algebraic contract a seeded parallel reduction relies on. Equivalent to `Associative` plus a declared zero such that `combine(zero, a) == a == combine(a, zero)`.

The `zero()` member names the identity element as a constant expression (for example `"0"`, `"''"`, or a fully-qualified static field reference). When supplied, tooling such as `groovy.typecheckers.CombinerChecker` can additionally check that the `seed` passed to `injectParallel` matches the declared identity where both are statically determinable. An empty value asserts associativity and the existence of an identity without naming it.

As with `Associative`, this annotation asserts the laws; it does not prove them. The assertion is intended to be backed by tests.

Since:
  6.0.0

- ## Optional Element Summary

  Optional Elements
  Modifier and Type
  Optional Element
  Description
  `String`
  `zero`
  The identity element, as a constant expression.

- ## Element Details

  - ### zero

    String zero
    The identity element, as a constant expression. Empty means the identity exists but is not named (associativity is still asserted).
    Default:
      ""