https://github.com/lucassklp/jinq
Java Integrated Query - LINQ for Java Programmers
https://github.com/lucassklp/jinq
java java-8 lambda linq linq-methods
Last synced: 2 months ago
JSON representation
Java Integrated Query - LINQ for Java Programmers
- Host: GitHub
- URL: https://github.com/lucassklp/jinq
- Owner: lucassklp
- License: mit
- Created: 2018-10-28T00:19:03.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2019-03-04T23:19:09.000Z (about 6 years ago)
- Last Synced: 2025-01-20T08:24:53.435Z (4 months ago)
- Topics: java, java-8, lambda, linq, linq-methods
- Language: Java
- Homepage:
- Size: 69.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jinq - Java Integrated Query - LINQ for Java
This library is inspired in [LINQ - Method Syntax (C#)](https://docs.microsoft.com/en-us/dotnet/csharp/linq/write-linq-queries) and helps Java programmers to manipulate list and its elements.
Examples of use:
```java
QueryableList 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 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 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> 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());```