/JLINQ

Java Language Integrated Query

Primary LanguageJavaOtherNOASSERTION

JLINQ

Java Language Integrated Query.

.NET LINQ equivalent. Create LINQ queries in Java.

Projects:

Name Description
JLINQ Contains core interfaces and default implementation for JLINQ queries.
[W.I.P.] JLINQ.Queryable Contains core interfaces for executing JLINQ queries on data sources.
[W.I.P.] JLINQ.Queryable.MySQL Contains query wrapper for MySQL database (MySqlQueryableJLinqWrapper).

To be implemented LINQ methods:

  • aggregate
  • all
  • any
  • asIterable
  • asNumbered (arithmetic operations - average, max, min, sum)
  • asParallel (parallel operations)
  • average
  • cast
  • concat
  • contains
  • count
  • defaultIfEmpty
  • distinct
  • elementAt
  • elementAtOrDefault
  • empty
  • except
  • first
  • firstOrDefault
  • forEach
  • groupBy
  • groupJoin
  • indexOf
  • intersect
  • join
  • last
  • lastOrDefault
  • longCount
  • max
  • min
  • orderBy
  • orderByDescending
  • range
  • repeat
  • replaceAt
  • replaceMultiple
  • reverse
  • select
  • selectMany
  • sequenceEqual
  • single
  • singleOrDefault
  • skip
  • skipWhile
  • sum
  • take
  • takeWhile
  • thenBy
  • thenByDescending
  • toArray
  • toList
  • toLookup
  • toMap
  • toSet
  • union
  • where
  • zip

TODO / FINISHED:

Examples:

  1. Retrieve some data.

C#:

using System.Linq;

int count = myEnumerable.Where((customer) => customer.Age == 24).Count();

Above example is equivalent with:

Java:

package jlinq; // Main package which contains all JLinq methods and classes.

// THERE ARE 2 WAYS OF USING JLINQ !!!

// In first method you can handle each method yourself using JLinq static methods.
Iterable<Customer> customersWithAge24Iterator = JLinq.where(customers, (customer) -> customer.age == 24);
List<Customer> customersWithAge24 = JLinq.toList(customersWithAge24Iterator);
int count = JLinq.count(customersWithAge24);

// In second method you can use wrapper for JLinq which will give you more freedom of using multiple method calls / streams:
// Where as constructor parameter you must specify the Iterable on which you want to use JLinq.
int wrapperCount = new JLinqWrapper<Customer>(customers).where((customer) -> customer.age == 24).count();