@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)
}
| Type | Name and Description |
|---|---|
String |
andReturns the replacement method name for the & operator.
|
String |
andAssignGEP-15: rename the dedicated compound-assignment method for &=. |
String |
compareToReturns the replacement method name for the spaceship operator. |
String |
divReturns the replacement method name for the / operator.
|
String |
divAssignGEP-15: rename the dedicated compound-assignment method for /=. |
String |
leftShiftReturns the replacement method name for the << operator.
|
String |
leftShiftAssignGEP-15: rename the dedicated compound-assignment method for <<=. |
String |
minusReturns the replacement method name for the - operator.
|
String |
minusAssignGEP-15: rename the dedicated compound-assignment method for -=. |
String |
multiplyReturns the replacement method name for the * operator.
|
String |
multiplyAssignGEP-15: rename the dedicated compound-assignment method for *=. |
String |
orReturns the replacement method name for the | operator.
|
String |
orAssignGEP-15: rename the dedicated compound-assignment method for |=. |
String |
plusReturns the replacement method name for the + operator.
|
String |
plusAssignGEP-15: rename the dedicated compound-assignment method for +=. |
String |
powerReturns the replacement method name for the ** operator.
|
String |
powerAssignGEP-15: rename the dedicated compound-assignment method for **=. |
String |
remainderReturns the replacement method name for the % operator.
|
String |
remainderAssignGEP-15: rename the dedicated compound-assignment method for %=. |
String |
rightShiftReturns the replacement method name for the >> operator.
|
String |
rightShiftAssignGEP-15: rename the dedicated compound-assignment method for >>=. |
String |
rightShiftUnsignedReturns the replacement method name for the >>> operator.
|
String |
rightShiftUnsignedAssignGEP-15: rename the dedicated compound-assignment method for >>>=. |
String |
xorReturns the replacement method name for the ^ operator.
|
String |
xorAssignGEP-15: rename the dedicated compound-assignment method for ^=. |
Returns the replacement method name for the & operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for &=.
Returns the replacement method name for the spaceship operator. Defaults to Undefined.STRING, meaning no rename.
Returns the replacement method name for the / operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for /=.
Returns the replacement method name for the << operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for <<=.
Returns the replacement method name for the - operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for -=.
Returns the replacement method name for the * operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for *=.
Returns the replacement method name for the | operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for |=.
Returns the replacement method name for the + operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for +=.
Returns the replacement method name for the ** operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for **=.
Returns the replacement method name for the % operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for %=.
Returns the replacement method name for the >> operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for >>=.
Returns the replacement method name for the >>> operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for >>>=.
Returns the replacement method name for the ^ operator.
Defaults to Undefined.STRING, meaning no rename.
GEP-15: rename the dedicated compound-assignment method for ^=.