Package: groovy.transform

## [Java] Annotation Type OperatorRename

- groovy.transform.OperatorRename

-     @Documented
      @Incubating
      @Retention(RetentionPolicy.SOURCE)
      @Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
      public @interface OperatorRename

  Allows renaming of Groovy's operator methods. This can be useful for using Groovy's operator overloading with libraries designed with different method names. As an example, here is using the Commons Numbers Fraction library. This normally has an "add" method, but we can use the "+" operator using this transform.

       @OperatorRename(plus="add")
       def testAddOfTwoFractions() {
           var half = Fraction.of(1, 2)
           var third = Fraction.of(1, 3)
           assert half + third == Fraction.of(5, 6)
       }

  Since:
    5.0.0

- - ### Element Summary

    Optional Element Summary
    Type | Name and Description
    --- | ---
    `String` | `and` Returns the replacement method name for the `&` operator.
    `String` | `andAssign` GEP-15: rename the dedicated compound-assignment method for `&=`.
    `String` | `compareTo` Returns the replacement method name for the spaceship operator.
    `String` | `div` Returns the replacement method name for the `/` operator.
    `String` | `divAssign` GEP-15: rename the dedicated compound-assignment method for `/=`.
    `String` | `isIn` Returns the replacement method name for the `in` membership operator (whose default method is `isIn`).
    `String` | `isNotIn` Returns the replacement method name for the {@code !
    `String` | `leftShift` Returns the replacement method name for the `<<` operator.
    `String` | `leftShiftAssign` GEP-15: rename the dedicated compound-assignment method for `<<=`.
    `String` | `minus` Returns the replacement method name for the `-` operator.
    `String` | `minusAssign` GEP-15: rename the dedicated compound-assignment method for `-=`.
    `String` | `multiply` Returns the replacement method name for the `*` operator.
    `String` | `multiplyAssign` GEP-15: rename the dedicated compound-assignment method for `*=`.
    `String` | `or` Returns the replacement method name for the `|` operator.
    `String` | `orAssign` GEP-15: rename the dedicated compound-assignment method for `|=`.
    `String` | `plus` Returns the replacement method name for the `+` operator.
    `String` | `plusAssign` GEP-15: rename the dedicated compound-assignment method for `+=`.
    `String` | `power` Returns the replacement method name for the `**` operator.
    `String` | `powerAssign` GEP-15: rename the dedicated compound-assignment method for `**=`.
    `String` | `remainder` Returns the replacement method name for the `%` operator.
    `String` | `remainderAssign` GEP-15: rename the dedicated compound-assignment method for `%=`.
    `String` | `rightShift` Returns the replacement method name for the `>>` operator.
    `String` | `rightShiftAssign` GEP-15: rename the dedicated compound-assignment method for `>>=`.
    `String` | `rightShiftUnsigned` Returns the replacement method name for the `>>>` operator.
    `String` | `rightShiftUnsignedAssign` GEP-15: rename the dedicated compound-assignment method for `>>>=`.
    `String` | `xor` Returns the replacement method name for the `^` operator.
    `String` | `xorAssign` GEP-15: rename the dedicated compound-assignment method for `^=`.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Element Detail

    - #### public String and

      Returns the replacement method name for the `&` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String andAssign

      GEP-15: rename the dedicated compound-assignment method for `&=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String compareTo

      Returns the replacement method name for the spaceship operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String div

      Returns the replacement method name for the `/` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String divAssign

      GEP-15: rename the dedicated compound-assignment method for `/=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String isIn

      Returns the replacement method name for the `in` membership operator (whose default method is `isIn`). Defaults to Undefined.STRING, meaning no rename. The receiver is the right operand (the container), so `a in b` dispatches to `b.name(a)`. Setting this to `'isCase'` restores the pre-GROOVY-9848 value-based membership for maps and char sequences within the annotated scope.

      This governs `in` only; `!in` is renamed separately via isNotIn(). To change membership consistently, set both (otherwise `in` and `!in` can disagree for maps and char sequences) -- for example `@OperatorRename(isIn='isCase', isNotIn='isNotCase')` to fully restore legacy behaviour.

      Returns:
        the replacement method name
      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String isNotIn

      Returns the replacement method name for the `!in` membership operator (whose default method is `isNotIn`). Defaults to Undefined.STRING, meaning no rename. The receiver is the right operand (the container), so `a !in b` dispatches to `b.name(a)`. Usually set together with isIn() so that `in` and `!in` stay consistent.

      Returns:
        the replacement method name
      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String leftShift

      Returns the replacement method name for the `<<` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String leftShiftAssign

      GEP-15: rename the dedicated compound-assignment method for `<<=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String minus

      Returns the replacement method name for the `-` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String minusAssign

      GEP-15: rename the dedicated compound-assignment method for `-=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String multiply

      Returns the replacement method name for the `*` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String multiplyAssign

      GEP-15: rename the dedicated compound-assignment method for `*=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String or

      Returns the replacement method name for the `|` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String orAssign

      GEP-15: rename the dedicated compound-assignment method for `|=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String plus

      Returns the replacement method name for the `+` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String plusAssign

      GEP-15: rename the dedicated compound-assignment method for `+=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String power

      Returns the replacement method name for the `**` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String powerAssign

      GEP-15: rename the dedicated compound-assignment method for `**=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String remainder

      Returns the replacement method name for the `%` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String remainderAssign

      GEP-15: rename the dedicated compound-assignment method for `%=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String rightShift

      Returns the replacement method name for the `>>` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String rightShiftAssign

      GEP-15: rename the dedicated compound-assignment method for `>>=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String rightShiftUnsigned

      Returns the replacement method name for the `>>>` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String rightShiftUnsignedAssign

      GEP-15: rename the dedicated compound-assignment method for `>>>=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING

    - #### public String xor

      Returns the replacement method name for the `^` operator. Defaults to Undefined.STRING, meaning no rename.

      Returns:
        the replacement method name
      Default:
        Undefined.STRING

    - #### public String xorAssign

      GEP-15: rename the dedicated compound-assignment method for `^=`.

      Since:
        6.0.0
      Default:
        Undefined.STRING