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.

有帮助吗?

解决方案

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

其他提示

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()
  }
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top