Closures in Java 7

This question already has an answer here: Closure in Java 7 [closed] 7 answers Have a look at http://www.javac.info/ . It seems like this is how it would look: boolean even = { int x => x % 2 == 0 }.invoke(15); where the { int x => x % 2 == 0 } bit is the closure. It really depends on what gets introduced, and indeed whether it will be introduced at all. There are a number of clo

Java 7中的闭包

这个问题在这里已经有了答案: 在Java 7中关闭[已关闭] 7个答案 看看http://www.javac.info/。 看起来这是它的外观: boolean even = { int x => x % 2 == 0 }.invoke(15); 其中{ int x => x % 2 == 0 }位是闭包。 这真的取决于什么被引入,并且实际上是否会被引入。 有不同规模的关闭建议。 有关提议和各种博客文章,请参阅Alex Miller的Java 7页面。 就我个人而言,我很想看到关闭 - 他们非常美丽,而且

Programmatically format and indent automatically generated source from Java

I wrote code generator that creates Java and C++ source code from custom IDL using Antlr. It works perfectly except for the Java code formatting. Currently I use Gnu Indent, but the format that it spits out is hardly readable and makes debugging a pain. I would love to use the same code formatter as NetBeans does (like when you press Alt+Shift+F) to format the generated files. What I do not w

以编程方式对Java自动生成的源进行格式化和缩进

我编写了代码生成器,它使用Antlr从自定义IDL创建Java和C ++源代码。 除Java代码格式外,它完美地工作。 目前我使用Gnu Indent,但它所吐出的格式几乎不可读,使调试变得很痛苦。 我希望使用与NetBeans相同的代码格式化程序(例如按Alt + Shift + F)格式化生成的文件。 我不想要的是通过每个这些文件并手动按下Alt + Shift + F。 我尝试过使用NetBeans API,但或者我没有在正确的地方寻找,或者Google是一个白痴,我找不到

Java Lambdas and Closures

I hear lambdas are coming soon to a Java near you (J8). I found an example of what they will look like on some blog: SoccerService soccerService = (teamA, teamB) -> { SoccerResult result = null; if (teamA == teamB) { result = SoccerResult.DRAW; } else if(teamA < teamB) { result = SoccerResult.LOST; } else { result = SoccerResult.WON; }

Java Lambdas和闭包

我听说lambdas即将到达你身边的Java(J8)。 我找到了他们在某个博客上看起来像什么的例子: SoccerService soccerService = (teamA, teamB) -> { SoccerResult result = null; if (teamA == teamB) { result = SoccerResult.DRAW; } else if(teamA < teamB) { result = SoccerResult.LOST; } else { result = SoccerResult.WON; } return result; }; 所以马

Does Java 8 Support Closures?

I'm confused. I thought Java8 was going to emerge from the stone age and start supporting lambdas / closures. But when I try: public static void main(String[] args) { int number = 5; ObjectCallback callback = () -> { return (number = number + 1); }; Object result = callback.Callback(); System.out.println(result); } it says that number should be effectively

Java 8是否支持闭包?

我很困惑。 我认为Java8将从石器时代出现并开始支持lambdas / closure。 但是当我尝试: public static void main(String[] args) { int number = 5; ObjectCallback callback = () -> { return (number = number + 1); }; Object result = callback.Callback(); System.out.println(result); } 它说这个number should be effectively final 。 那是呃,不是我想的封闭。 这听起来像是在

Why is Java Lambda also called Closures

This question already has an answer here: What is the difference between a 'closure' and a 'lambda'? 10 answers Those are two different terms that happen to often be mentioned in the same context. A lambda is basically just an anonymous function. Example: () -> System.out.println("Hello") . It's a function, but it doesn't have a name. A closure is a

为什么Java Lambda也称为闭包

这个问题在这里已经有了答案: '封'和'lambda'有什么区别? 10个答案 这些是在相同的背景下经常提到的两个不同的术语。 拉姆达基本上只是一个匿名函数。 例如:( () -> System.out.println("Hello") 。 这是一个功能,但它没有名称。 封闭是关于范围界定的术语。 例如,在lambda中引用一个局部变量时,如下所示 int localInt = 17; saveThisFunction(() -> System.out.println(lo

arg and property together in bean definition

<bean id="cObject" scope="request" class="x.y.z.CClass"/> <bean id="bObject" scope="request" class="x.y.z.BClass"/> <bean id="aObject" scope="request" class="x.y.z.AClass"> <constructor-arg ref="bObject" /> <property name="cRef" ref="cObject" /> </bean> aObject.cRef is not getting set for some reason. Note that constructor-arg and property are used in

arg和属性一起在bean中定义

<bean id="cObject" scope="request" class="x.y.z.CClass"/> <bean id="bObject" scope="request" class="x.y.z.BClass"/> <bean id="aObject" scope="request" class="x.y.z.AClass"> <constructor-arg ref="bObject" /> <property name="cRef" ref="cObject" /> </bean> 由于某种原因aObject.cRef没有被设置。 请注意,constructor-arg和property在相同的定义中使用。 我还没

Single java application instance per network

We have deployed a java application which will be run by a job scheduler. This application might be run on many different server machines of intranet. Now we had a problem that there might be more than one instance of this application running simultaneously on multiple machine of product env, and that's a nightmare and we must to avoid that. So I would like to know what's the proper

每个网络一个Java应用程序实例

我们已经部署了一个将由作业调度器运行的Java应用程序。 此应用程序可能在Intranet的许多不同服务器上运行。 现在我们遇到了一个问题,这个应用程序中可能有多个实例同时在多个产品env机器上运行,这是一场噩梦,我们必须避免这种情况。 所以我想知道确保每个网络只能运行一个应用程序实例的正确方法是什么。

GWT RPC serialization for Dynamic Host Page

I implemented a Dynamic Host Page (http://www.gwtproject.org/articles/dynamic_host_page.html) in my GWT project to pass my User POJO object directly in it. I did it with AutoBean (https://code.google.com/p/google-web-toolkit/wiki/AutoBean) so I had to declare and implement Interfaces But I found this way a little bit too verbose. Is there another way? I mean GWT RPC do serialization withou

动态主机页面的GWT RPC序列化

我在我的GWT项目中实现了一个动态主机页面 (http://www.gwtproject.org/articles/dynamic_host_page.html),以便直接将我的用户 POJO对象传递给它。 我使用AutoBean(https://code.google.com/p/google-web-toolkit/wiki/AutoBean)完成了这个工作,所以我必须声明和实现接口 但我发现这种方式有点过于冗长。 有另一种方法吗? 我的意思是GWT RPC没有接口的序列化,所以我可以使用它? 另一点; 我已经使用gwt-storag

gwt hosted mode hangs on connecting to 127.0.0.1

i am using gwt for a while (pretty nice and useful thing) when i run the hosted mode i am getting the hosted browser window, and it hangs on "connecting to 127.0.0.1", only after few tires it works well. anyone encountered this behavior? please advise oops forgot to mention that i am using windows XP, GWT 3.5, and eclipse version Galileo Hosted mode has issues connecting if th

gwt托管模式在连接到127.0.0.1时挂起

我使用gwt一段时间(相当不错和有用的东西) 当我运行托管模式,我得到托管的浏览器窗口,并挂在“连接到127.0.0.1”,只有几个轮胎后,它运作良好。 任何人遇到这种行为? 请指教 哎呀忘了提及我使用的是Windows XP,GWT 3.5和Eclipse版本的Galileo 如果可用内存不足,主机模式会连接问题。 重新启动浏览器和Eclipse并重试。 下一次它碰巧检查剩余空闲RAM的数量来确认这一点。

Good Java graph algorithm library?

Has anyone had good experiences with any Java libraries for Graph algorithms. I've tried JGraph and found it ok, and there are a lot of different ones in google. Are there any that people are actually using successfully in production code or would recommend? To clarify, I'm not looking for a library that produces graphs/charts, I'm looking for one that helps with Graph algorithms,

好的Java图形算法库?

有没有人对Graph算法的任何Java库有很好的经验。 我试过JGraph,发现它没问题,而且谷歌里有很多不同的东西。 有没有人实际使用生产代码或推荐? 为了澄清,我没有寻找一个产生图形/图表的库,我正在寻找一个可以帮助图形算法的库,例如最小生成树,克鲁斯卡尔算法节点,边等等。理想情况下,一个算法/数据很好结构在一个不错的Java OO API中。 如果你使用的是JGraph,你应该尝试一下为算法设计的JGraphT。 它的一个特点