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: about 1 month 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 7 years ago)
- Default Branch: develop
- Last Pushed: 2019-03-04T23:19:09.000Z (over 7 years ago)
- Last Synced: 2026-01-01T15:21:09.058Z (5 months ago)
- Topics: java, java-8, lambda, linq, linq-methods
- Language: Java
- Homepage:
- Size: 69.3 KB
- Stars: 1
- Watchers: 2
- 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", "tom@example.com", 40.2F));
users.add(new User(26, "Clark", "clark@example.com", 62.7F));
users.add(new User(52, "Marie", "marie@example.com", 54.7F));
users.add(new User(37, "Peter", "peter@example.com", 87.7F));
users.add(new User(10, "Cleber", "cleber@example.com", 47.7F));
users.add(new User(10, "John", "john@example.com", 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("clark@example.com"));
//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());
```