10

Possible Duplicate:
What is the Java equivalent for LINQ?

There are numerous questions asking whether there is a Java equivalent for LINQ. But most of them are incorrectly specifying that there is nothing.

Community
  • 1
  • 1
Scooterville
  • 456
  • 1
  • 3
  • 12
  • 2
    `most of them are incorrectly specifying that there is nothing` - then why are you asking the question if you are so sure they are "incorrectly specifying that there is nothing"? – Tudor Jun 04 '12 at 10:24
  • What are you trying to do here? First you ask a question where you state that answers to other similar questions are incorrect and then you answer yourself by linking to a project. Is it something you are involved in and want to market or what? – Fredrik Jun 04 '12 at 10:27
  • 2
    I come from a .NET background and I'm using this library. When researching for something like this all I saw was "No there is nothing". So it's for others who have to use Java for a project. – Scooterville Jun 04 '12 at 10:34
  • 3
    @Fredrik: this is [acceptable and even encouraged](http://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/). – Greg Kopff Jun 04 '12 at 10:42
  • 1
    @GregKopff Even if there are other questions that ask the same thing? Couldn't he just have answered one of that questions saying that the other answers were wrong? – Pablo Jun 04 '12 at 10:46
  • 1
    @Pable but these are already answered and accepted – Scooterville Jun 04 '12 at 10:52
  • @Pablo: yes, that part is true - I agree. – Greg Kopff Jun 04 '12 at 10:53
  • @GregKopff I know and I didn't say it wasn't. I was just wondering about the idea behind rejecting answers to similar questions as incorrect and then add this instead of answering the other questions. – Fredrik Jun 04 '12 at 11:25

2 Answers2

20

This library provides a full LINQ API: https://github.com/nicholas22/jpropel-light

It does so with functional-style constructs and it also uses deferred execution.

// select names starting with j, using LINQ-style statements
new String[] { "james", "john", "john", "eddie" }.where(startsWith("j")).distinct().all(println());
Scooterville
  • 456
  • 1
  • 3
  • 12
  • 12
    No lambdas, no cigar. The ability to take _expressions_, and break them down to their components, and translate those into a SQL expression for complex hierarchical queries is still missing completely. – DaveMorganTexas May 10 '13 at 07:15
  • 8
    @DaveMorganTexas LINQ-to-SQL != LINQ. – Evan Plaice Feb 19 '14 at 02:44
  • 1
    @EvanPlaice - the appropriate terminology would be `query expression`, not `SQL expression`. If Dave were able to make that replacement, his comment would become more universally applicable, rather than only in the realm of SQL – Code Jockey Feb 23 '16 at 17:54
  • 1
    As pointed out in comments in [What is the Java equivalent for LINQ?](https://stackoverflow.com/questions/1217228/what-is-the-java-equivalent-for-linq), changes to C# and the .Net framework were required -- Lambdas, extension methods -- and only **then** were they able to create the libraries of methods that are the LINQ-providers. Until they make the deep changes in Java, all "LINQ APIs" are going to be shallow cheap imitations, bolt-on "decorators" that in the end will still require tons of code to properly "work around" the lack of deep integration achieved in LINQ. – MicroservicesOnDDD May 28 '20 at 17:08
4

Another one that I've tried myself is jaque: http://code.google.com/p/jaque/

Tudor
  • 61,523
  • 12
  • 102
  • 142