Skip to content

Java INtegrated Query in parlance with LINQ is an ultra minimalistic library for Java inspired from and mimicking the .NET LINQ. While LINQ is a language construct, JINQ is composed of types - classes and methods, but to the same effect.

vivekragunathan/JINQ

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 

JINQ

Java INtegrated Query in parlance with LINQ is an ultra minimalistic library for Java inspired from and mimicking the .NET LINQ. While LINQ is a language construct, JINQ is composed of types - classes and methods, but to the same effect.

JINQ allows you to rewrite conventional and nested loop based data processing code into query oriented and highly readable code.

Here is a typical loop based data processing code:

List<ProductDisplayInfo> getDisplayList(Product[] products) {
	List<ProductDisplayInfo> pdiList = new ArrayList<>();

	for (int index = 0; index < products.length; ++index) {
		Product p = products[index];

		if (product.getCategory() == 2 || product.getCategory() == 5) {
			boolean yes = isProductUnderDiscount(product);

			if (!yes) {
				ProductDisplayInfo pdi = new ProductDisplayInfo();
				// whatever you want to populate pdi with ...

				pdiList.add(pdi);
			}
		}
	}

	return pdiList;
}

Here is a C# LINQ snippet:

var query = from p in products
	where p.getCategory == 2 || p.getCategory == 5 && isProductUnderDiscount(p)
	select new ProductDisplayInfo(p);

var pdiList = query.ToList();

Here is JINQ in action:

final Iterable<ProductDisplayInfo> query = new Enumerable<>(products)
	.where(p -> p.getCategory == 2 || p.getCategory == 5 && isProductUnderDiscount(p))
	.select(p -> { new ProductDisplayInfo(p); } ); // or select(ProductDisplayInfo::new);

final List<ProductDisplayInfo> pdiList = query.toList();

or

for (ProductDisplayInfo pdi : pdiList) {
	System.out.println(pdi);
}

Elaboration of JINQ is in progress. Until then you can try the related blog post.

About

Java INtegrated Query in parlance with LINQ is an ultra minimalistic library for Java inspired from and mimicking the .NET LINQ. While LINQ is a language construct, JINQ is composed of types - classes and methods, but to the same effect.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages