Question

I find it odd that I couldn't find anyone asking about this before. But is it impossible to use static methods in XTend??

I'm using the play framework and the controller objects require your methods to be static. So does XTend really just not support static methods and I can't use it with play(So much) now?

Other than this I haven't had any other problems mixing Play! and XTend.

Thank you for any help.

Was it helpful?

Solution

The latest release has support for statics:

def static void main(String[] args) {
  println("Hello World")
}

See https://www.eclipse.org/xtend/documentation/202_xtend_classes_members.html#methods

OTHER TIPS

My Xtext 2.0.0 does not support static methods too. You can use the external Java Class with static fields.

".java" file:

package org.some.pack1;
  class MyClassHelper {
    static Object f1(){
      return //... ;
    }
  }

".xtend" file:

package org.some.pack2
import static extension org.some.pack1.MyClassHelper.*
class MyClass  {
  def /*static*/ f1(){
    MyClassHelper::f1()
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top