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?
.where(b -> b.getIban() == "SomeIban")
instead ofWHERE IBAN = 'SomeIban'
(as part of an SQL statement)? It would be powerful if it could translate arbitrary Java code but the corresponding C# feature is limited to simple expressions so it stops right where it could start to become useful…