Skip to content

mbalabanski/Linq.java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Linq in Java

A light-weight java implementation of LINQ (Language Integrated Query)

Usage

Linq's constructor takes in a dataset which can be a List<> or an Array.

Linq creates a query and needs its criteria specified using its where() method.

Integer[] data = {20, 40, 60, 80};

int eighty = new Query(data).where(new Equals(80)).first();

To fetch the data, one can use either the first() or all() methods. first() returns the first element that matches the criteria given. all() returns every element that matches the criteria in a List<>.

Built in Criteria

Linq comes with 6 built-in criterias: Equals, GreaterThan, GreaterThanOrEqualTo, LessThan, LessThanOrEqualTo, and NotEquals.
However, a criteria can be created with a lambda:

ICriteria<Integer> criteria = (Integer item) -> item > 20 && item < 80;

Tests

Run tests with:

$ gradle test

About

A java implementation of Linq

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages