Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing and Translating Java 8 lambda expressions

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.

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

and then return the result to the client. Any idea if this is even possible in Java?

like image 227
Eyad Avatar asked Sep 23 '14 07:09

Eyad


1 Answers

Yes, it's possible. I made a library that does exactly that: JaQue

like image 135
Konstantin Triger Avatar answered Oct 08 '22 23:10

Konstantin Triger