{"id":22377858,"url":"https://github.com/klemek/betterlists","last_synced_at":"2026-01-14T02:36:51.830Z","repository":{"id":57720781,"uuid":"122372458","full_name":"klemek/BetterLists","owner":"klemek","description":"An extension of java List interface which include some of the C# LINQ useful functions.","archived":true,"fork":false,"pushed_at":"2020-10-12T19:09:38.000Z","size":90,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-31T00:25:24.264Z","etag":null,"topics":["java","java-8","java-library","java8","linq","linq-methods","maven","maven-repository"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klemek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-21T17:57:16.000Z","updated_at":"2024-12-03T15:29:18.000Z","dependencies_parsed_at":"2022-09-05T16:50:55.858Z","dependency_job_id":null,"html_url":"https://github.com/klemek/BetterLists","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/klemek/BetterLists","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klemek%2FBetterLists","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klemek%2FBetterLists/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klemek%2FBetterLists/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klemek%2FBetterLists/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klemek","download_url":"https://codeload.github.com/klemek/BetterLists/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klemek%2FBetterLists/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","java-8","java-library","java8","linq","linq-methods","maven","maven-repository"],"created_at":"2024-12-04T22:15:51.930Z","updated_at":"2026-01-14T02:36:51.811Z","avatar_url":"https://github.com/klemek.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BetterLists\r\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.klemek/betterlists.svg)](https://search.maven.org/search?q=g:%22com.github.klemek%22%20AND%20a:%22betterlists%22)\r\n[![Build Status](https://img.shields.io/travis/Klemek/BetterLists.svg?style=popout)](https://travis-ci.org/Klemek/BetterLists)\r\n[![Scc Count Badge](https://sloc.xyz/github/klemek/betterlists/?category=code)](https://github.com/boyter/scc/#badges-beta)\r\n[![Coverage Status](https://img.shields.io/coveralls/github/Klemek/BetterLists.svg)](https://coveralls.io/github/Klemek/BetterLists?branch=master)\r\n![License](https://img.shields.io/github/license/Klemek/BetterLists.svg)\r\n[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/Klemek/BetterLists.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/Klemek/BetterLists/context:java)\r\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/Klemek/BetterLists.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/Klemek/BetterLists/alerts/)\r\n\r\nAn extension of the java.util.List interface which include some of the C# LINQ useful functions.\r\n\r\nList classes are extended as well. (ArrayList -\u003e BetterArrayList)\r\n\r\nCurrent version v1.4\r\n\r\nBefore BetterLists :\r\n```Java\r\nArrayList\u003cContact\u003e contacts = someFunction();\r\n\r\nArrayList\u003cString\u003e contactsEmails = new ArrayList\u003c\u003e();\r\nfor(int i = 5; i \u003c contacts.size(); i++){\r\n\tif(c.getEmail() != null){\r\n\t\tcontactsEmails.add(c.getEmail());\r\n\t}\r\n}\r\n```\r\nWith BetterLists :\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nBetterList\u003cString\u003e contactsEmails = contacts.skip(5)\r\n\t\t\t\t\t.where(c -\u003e c.getEmail() != null)\r\n\t\t\t\t\t.\u003cString\u003eselect(c -\u003e c.getEmail());\r\n```\r\n\r\nNOTE : Please note that, unlike C# LINQ, these functions are not optimized at low levels and will have the same impact as standard loops in your program. \r\n\r\n## Download\r\n\r\n[betterlists-1.4.jar](../../releases/download/betterlists-1.4/betterlists-1.4.jar)\r\n\r\n## Maven\r\n\r\nYou can use this project as a maven dependency with this :\r\n```XML\r\n\u003cdependency\u003e\r\n    \u003cgroupId\u003ecom.github.klemek\u003c/groupId\u003e\r\n    \u003cartifactId\u003ebetterlists\u003c/artifactId\u003e\r\n    \u003cversion\u003e1.4\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\n## All code examples\r\n### List\r\n\r\n| Name | Description |\r\n| :- | :- |\r\n| [all](#all) | Determines whether all elements of the sequence satisfy a condition. |\r\n| [any](#any) | Determines whether any element of the sequence satisfies a condition. |\r\n| [count](#count) | Returns a number that represents how many elements in the specified sequence satisfy a condition. |\r\n| [exclusion](#exclusion) | Produces the set exclusion of two sequences. |\r\n| [first / firstOrDefault](#first-firstordefault) | Returns the first element in the sequence that satisfies a specified condition. (Returns an error if no elements match the condition unless you use the firstOrDefault function) |\r\n| [last / lastOrDefault](#last-lastordefault) | Returns the last element in the sequence that satisfies a specified condition. (Returns an error if no elements match the condition unless you use the lastOrDefault function) |\r\n| [max](#max) | Invokes a transform function on each element of the sequence and returns the maximum nullable Double value. |\r\n| [mean](#mean) | Computes the mean of the sequence of Double values that are obtained by invoking a transform function on each element of the input sequence. |\r\n| [min](#min) | Invokes a transform function on each element of the sequence and returns the minimum nullable Double value. |\r\n| [orderBy / orderByDescending](#orderby-orderbydescending) | Sorts the elements of a sequence in ascending order by using a specified comparator. (You can user orderByDescending to change the order) |\r\n| [reverse](#reverse) | Inverts the order of the elements in the sequence. |\r\n| [select](#select) | Projects each element of a sequence into a new form. |\r\n| [selectMany / selectManyArrays](#selectmany-selectmanyarrays) | Projects each element of a sequence into a new list and flattens the resulting sequences into one sequence. |\r\n| [skip / skipWhile](#skip-skipwhile) | Bypasses elements in the sequence as long as a specified condition is true and then returns the remaining elements. |\r\n| [sum](#sum) | Computes the sum of the sequence of Double values that are obtained by invoking a transform function on each element of the input sequence. |\r\n| [take / takeWhile](#take-takewhile) | Returns a specified number of contiguous elements from the start of the sequence. |\r\n| [union](#union) | Produces the set union of two sequences. |\r\n| [where](#where) | Filters a sequence of values based on a predicate. |\r\n\r\n### all\r\nDetermines whether all elements of the sequence satisfy a condition.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nboolean allAdults = contacts.all(c -\u003e c.getAge() \u003e= 21);\r\n```\r\n\r\n### any\r\nDetermines whether any element of the sequence satisfies a condition.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nboolean someUnderage = contacts.any(c -\u003e c.getAge() \u003c 21);\r\n```\r\n\r\n### count\r\nReturns a number that represents how many elements in the specified sequence satisfy a condition.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nint adultsCount = contacts.count(c -\u003e c.getAge() \u003e= 21);\r\n```\r\n\r\n### exclusion\r\nProduces the set exclusion of two sequences.\r\n```Java\r\nBetterArrayList\u003cContact\u003e frenchContacts = BetterArrayList.fromList(someFunction());\r\nArrayList\u003cContact\u003e validContacts = someOtherFunction();\r\n\r\nBetterList\u003cContact\u003e invalidFrenchContacts = frenchContacts.exclusion(validContacts);\r\n```\r\n\r\n### first / firstOrDefault\r\nReturns the first element in the sequence that satisfies a specified condition. (Throws an error if no elements match the condition unless you use the `firstOrDefault` function)\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nContact firstManager = contacts.first(c -\u003e c.isManager()); //can throw NoSuchElementException\r\nContact firstContact = contacts.firstOrDefault(null); //return null if the list is empty\r\n```\r\n\r\n### last / lastOrDefault\r\nReturns the last element in the sequence that satisfies a specified condition. (Throws an error if no elements match the condition unless you use the `lastOrDefault` function)\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nContact lastRegular = contacts.last(c -\u003e !c.isManager()); //can throw NoSuchElementException\r\nContact lastManager = contacts.lastOrDefault(c -\u003e c.isManager(), null); //return null there is no manager\r\n```\r\n\r\n### max\r\nInvokes a transform function on each element of the sequence and returns the maximum nullable Double value.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nint maxAge = (int)contacts.max(c -\u003e (double)c.getAge());\r\n```\r\n\r\n### mean\r\nComputes the mean of the sequence of Double values that are obtained by invoking a transform function on each element of the input sequence.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nint meanAge = (int)contacts.mean(c -\u003e (double)c.getAge());\r\n```\r\n\r\n### min\r\nInvokes a transform function on each element of the sequence and returns the minimum nullable Double value.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nint minAge = (int)contacts.min(c -\u003e (double)c.getAge());\r\n```\r\n\r\n### orderBy / orderByDescending\r\nSorts the elements of a sequence in ascending order by using a specified comparer. (You can user `orderByDescending` to change the order)\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nBetterList\u003cContact\u003e orderedContacts = contacts.orderBy(c -\u003e c.getName);\r\nBetterList\u003cContact\u003e orderedContacts2 = contacts.orderByDescending(c -\u003e c.getAge()); //oldest first\r\n```\r\n\r\n### reverse\r\nInverts the order of the elements in the sequence.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nBetterList\u003cContact\u003e reversedContacts = contacts.reverse();\r\n```\r\n\r\n### select\r\nProjects each element of a sequence into a new form.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nBetterList\u003cString\u003e contactsMails = contacts.select(c -\u003e c.getEmail());\r\n```\r\n\r\n### selectMany / selectManyArrays\r\nProjects each element of a sequence into a new list and flattens the resulting sequences into one sequence.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nBetterList\u003cString\u003e contactsNumbers = contacts.selectMany(c -\u003e c.getAllPhoneNumbers());\r\nBetterList\u003cString\u003e contactsMails = contacts.selectManyArrays(c -\u003e c.getEmail().split(\";\"));\r\n```\r\n\r\n\r\n### skip / skipWhile\r\nBypasses elements in the sequence as long as a specified condition is true and then returns the remaining elements.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nBetterList\u003cContact\u003e contacts2 = contacts.skip(3);\r\nBetterList\u003cContact\u003e contacts3 = contacts.skipWhile(c -\u003e c.getEmail().startsWith(\"society\"));\r\n```\r\n\r\n### sum\r\nComputes the sum of the sequence of Double values that are obtained by invoking a transform function on each element of the input sequence.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\ndouble salary = contacts.skip(c -\u003e c.getSalary());\r\n```\r\n\r\n### take / takeWhile\r\nReturns a specified number of contiguous elements from the start of the sequence.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nBetterList\u003cContact\u003e contacts2 = contacts.take(5);\r\nBetterList\u003cContact\u003e contacts3 = contacts.takeWhile(c -\u003e c.getEmail().startsWith(\"society\"));\r\n```\r\n\r\n### union\r\nProduces the set union of two sequences.\r\n```Java\r\nBetterArrayList\u003cContact\u003e frenchContacts = BetterArrayList.fromList(someFunction());\r\nArrayList\u003cContact\u003e validContacts = someOtherFunction();\r\n\r\nBetterList\u003cContact\u003e validFrenchContacts = frenchContacts.union(validContacts);\r\n```\r\n\r\n### where\r\nFilters a sequence of values based on a predicate.\r\n```Java\r\nBetterArrayList\u003cContact\u003e contacts = BetterArrayList.fromList(someFunction());\r\n\r\nBetterList\u003cContact\u003e validContacts = contacts.where(c -\u003e c.getEmail() != null);\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklemek%2Fbetterlists","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklemek%2Fbetterlists","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklemek%2Fbetterlists/lists"}