Reputation: 233
I know that its possible to redefine operands with Xtend. My question is, can I redefine an operand using Xtend code and then import this source code into Java project to use it?
For example I would redefine the operand +
with Xtend, than I import this source into my Java project and use the redefined operand. Is it possible?
Upvotes: 0
Views: 259
Reputation: 22650
Create or copy an Xtend file into a Java project, then just open it, this will install the Xtend builder on the project. Now, you will have a problem marker on the first line of code, quick fix it with Ctrl+1, this will add the necessary Xtend libs to the classpath. That's all.
Source: the Getting Started section of Xtend's installation instructions.
Note: as @rzymek says, you will be able to use the overriden operator only in Xtend, Java will only see the method operator_plus
.
Upvotes: 1
Reputation: 9281
You can't redefine operators in Java. You can in Xtend.
Xtend compiler will generate e1.operator_plus(e2)
Java code, when you're calling an overriden +
operator.
Upvotes: 2