Tool to Delambdafy Java code from Java 8 to Java 7 syntax? [closed]

一世执手 提交于 2019-12-01 19:19:12

In IntelliJ Idea open 'Project Structure' and then set Project language level to 7.0. Analyze your code again if that is needed. That will help in most of the cases but prefer to do it class by class (file by file) basis.

You can try this. It's one person's proof-of-concept to do something close to what you are asking:

It can convert a variable declaration for a functional interface with a lambda initializer into a anonymous inner class.

e.g.:

Callable<String> callable = () -> "abc" ;

// Converted to:

Callable<String> callable = new Callable<String>() {
    public String call() throws java.lang.Exception { 
        return "abc"; 
    }
};

I don't know if it can convert anonymous lambdas (i.e. those not declared as a variable) or Method References (e.g. Person::compareByAge), or closures (local variable capture), but those might be features you can extend his code to do if you need them.

The author notes that "It's a long way from being feature complete, but it's usable..."

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!