Skip to content
/ jinq Public

Java Integrated Query - LINQ for Java Programmers

License

Notifications You must be signed in to change notification settings

lucassklp/jinq

Repository files navigation

jinq - Java Integrated Query - LINQ for Java

This library is inspired in LINQ - Method Syntax (C#) and helps Java programmers to manipulate list and its elements.

Examples of use:

QueryableList<User> users = new QueryableList<>();

users.add(new User(10, "Tom", "[email protected]", 40.2F));
users.add(new User(26, "Clark", "[email protected]", 62.7F));
users.add(new User(52, "Marie", "[email protected]", 54.7F));
users.add(new User(37, "Peter", "[email protected]", 87.7F));
users.add(new User(10, "Cleber", "[email protected]", 47.7F));
users.add(new User(10, "John", "[email protected]", 50.7F));

//Do the Map operation over user list
QueryableList<Integer> map = users.map(x -> x.getAge());

//Find the first element that matches with predicate
User ageTen = users.find(x -> x.getAge() == 10);

//Find all elements that matches with predicate
QueryableList<User> listAgeTen = users.findAll(x -> x.getAge() == 10);

//Remove all elements that matches with predicate
users.removeAll(x -> x.getAge() == 10);

//Remove first elements that matches with predicate
users.remove(x -> x.getEmail().equals("[email protected]"));

//Group the list by age
QueryableList<Group<Integer, User>> ageGroup = Group.of(users, it -> it.getAge());

//Get the max value from List
User older = users.max(x -> x.getAge());

//Get the max value from List
User newer = users.min(x -> x.getAge());

About

Java Integrated Query - LINQ for Java Programmers

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published