解析和翻译的Java 8拉姆达前pressions [英] Parsing and Translating Java 8 lambda expressions
问题描述
在C#中你可以附上在离pression树对象的lambda前pression,然后有可能的解析它。我想知道,这也有可能在Java中?
In C# you can enclose a lambda expression in an expression tree object and then possibly parse it. I was wondering if this is also possible in Java?
我正在寻找的是做这样的事情:
What I'm looking for is doing something like this:
BooksRepository.getAll()
.where(b -> b.getIban() == "SomeIban")
.and(b -> b.getAuthor() == "SomeAuthor"); //etc.
和则 BooksRepository
应该以某种方式把所查询的基础上指定的lambda表达式predicates以下的RESTful API请求:
And then the BooksRepository
should somehow translate that query to the following RESTful API request based on the predicates specified as lambdas:
GET http://mylibrary.com/books?Iban=SomeIban&Author=SomeAuthor
,然后将结果返回给客户端。任何想法,如果这甚至有可能在Java中?
and then return the result to the client. Any idea if this is even possible in Java?
推荐答案
是的,这是可能的。我所做的正是这么做的图书馆:哈克
Yes, it's possible. I made a library that does exactly that: JaQue
这篇关于解析和翻译的Java 8拉姆达前pressions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!