{"id":13485830,"url":"https://github.com/jOOQ/jOOL","last_synced_at":"2025-03-27T19:31:50.599Z","repository":{"id":14621849,"uuid":"17339218","full_name":"jOOQ/jOOL","owner":"jOOQ","description":"jOOλ - The Missing Parts in Java 8 jOOλ improves the JDK libraries in areas where the Expert Group's focus was elsewhere. It adds tuple support, function support, and a lot of additional functionality around sequential Streams. The JDK 8's main efforts (default methods, lambdas, and the Stream API) were focused around maintaining backwards compatibility and implementing a functional API for parallelism.","archived":false,"fork":false,"pushed_at":"2024-08-01T12:21:02.000Z","size":1842,"stargazers_count":2104,"open_issues_count":45,"forks_count":170,"subscribers_count":82,"default_branch":"main","last_synced_at":"2025-03-25T23:17:37.882Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.jooq.org/products","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/jOOQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-03-02T14:27:38.000Z","updated_at":"2025-03-09T02:35:03.000Z","dependencies_parsed_at":"2022-07-15T18:00:37.601Z","dependency_job_id":"15d7969e-8c6d-4f01-ac35-543e72073e86","html_url":"https://github.com/jOOQ/jOOL","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jOOQ%2FjOOL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jOOQ","download_url":"https://codeload.github.com/jOOQ/jOOL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245910929,"owners_count":20692518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-07-31T18:00:32.203Z","updated_at":"2025-03-27T19:31:49.677Z","avatar_url":"https://github.com/jOOQ.png","language":"Java","readme":"jOOλ\r\n====\r\n\r\njOOλ is part of the jOOQ series (along with jOOQ, jOOX, jOOR, jOOU) providing some useful extensions to Java 8 lambdas. It contains these classes:\r\n\r\norg.jooq.lambda.function\r\n------------------------\r\n\r\nWhy only `Function` and `BiFunction`? We have also included support for `Function1` through `Function16`.\r\n\r\norg.jooq.lambda.tuple\r\n---------------------\r\n\r\nTuple support is essential in functional programming. A variety of things can be modelled as tuples, e.g. function argument lists. This is why we support type safe `Tuple1` through `Tuple16` types.\r\n\r\norg.jooq.lambda.Seq\r\n-------------------\r\n\r\nThe new Streams API was implemented to provide filter/map/reduce-like operations leveraging the new lambdas.\r\nMany of the useful methods that we know from other functional languages (e.g Scala) are missing. This is why jOOλ knows\r\na `Seq` (short of _Sequential_) interface that extends `Stream` and adds a variety of additional methods to.\r\n\r\nPlease note that all `Seq`'s are **sequential and ordered streams**, so don't bother to call `parallel()` on it, it will\r\nreturn the same `Seq`.\r\n\r\n`Seq` adds a handful of useful methods, such as:\r\n\r\n```java\r\n// (1, 2, 3, 4, 5, 6)\r\nSeq.of(1, 2, 3).concat(Seq.of(4, 5, 6));\r\n\r\n// true\r\nSeq.of(1, 2, 3, 4).contains(2);\r\n\r\n// true\r\nSeq.of(1, 2, 3, 4).containsAll(2, 3);\r\n\r\n// true\r\nSeq.of(1, 2, 3, 4).containsAny(2, 5);\r\n\r\n// (tuple(1, \"A\"), tuple(1, \"B\"), tuple(2, \"A\"), tuple(2, \"B\"))\r\nSeq.of(1, 2).crossJoin(Seq.of(\"A\", \"B\"));\r\n\r\n// (tuple(1, 1), tuple(1, 2), tuple(2, 1), tuple(2, 2))\r\nSeq.of(1, 2).crossSelfJoin()\r\n\r\n// (1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, ...)\r\nSeq.of(1, 2, 3).cycle();\r\n\r\n// tuple((1, 2, 3), (1, 2, 3))\r\nSeq.of(1, 2, 3).duplicate();\r\n\r\n// \"!abc\"\r\nSeq.of(\"a\", \"b\", \"c\").foldLeft(\"!\", (u, t) -\u003e u + t);\r\n\r\n// \"abc!\"\r\nSeq.of(\"a\", \"b\", \"c\").foldRight(\"!\", (t, u) -\u003e t + u);\r\n\r\n// { 1 = (1, 3), 0 = (2, 4) }\r\nSeq.of(1, 2, 3, 4).groupBy(i -\u003e i % 2);\r\n\r\n// (tuple(1, (1, 3)), tuple(0, (2, 4)))\r\nSeq.of(1, 2, 3, 4).grouped(i -\u003e i % 2);\r\n\r\n// (tuple(1, 1), tuple(2, 2))\r\nSeq.of(1, 2, 4).innerJoin(Seq.of(1, 2, 3), (a, b) -\u003e a == b);\r\n\r\n// (tuple(1, 2), tuple(2, 1))\r\nSeq.of(1, 2).innerSelfJoin((t, u) -\u003e t != u)\r\n\r\n// (1, 0, 2, 0, 3, 0, 4)\r\nSeq.of(1, 2, 3, 4).intersperse(0);\r\n\r\n// \"123\"\r\nSeq.of(1, 2, 3).join();\r\n\r\n// \"1, 2, 3\"\r\nSeq.of(1, 2, 3).join(\", \");\r\n\r\n// \"^1|2|3$\"\r\nSeq.of(1, 2, 3).join(\"|\", \"^\", \"$\"); \r\n\r\n// (tuple(1, 1), tuple(2, 2), tuple(4, null))\r\nSeq.of(1, 2, 4).leftOuterJoin(Seq.of(1, 2, 3), (a, b) -\u003e a == b);\r\n\r\n// (tuple(tuple(1, 0), NULL), tuple(tuple(2, 1), tuple(1, 0)))\r\nSeq.of(tuple(1, 0), tuple(2, 1)).leftOuterSelfJoin((t, u) -\u003e t.v2 == u.v1)\r\n\r\n// (1, 2)\r\nSeq.of(1, 2, 3, 4, 5).limitWhile(i -\u003e i \u003c 3);\r\n\r\n// (1, 2)\r\nSeq.of(1, 2, 3, 4, 5).limitUntil(i -\u003e i == 3);\r\n\r\n// (1, 2L)\r\nSeq.of(new Object(), 1, \"B\", 2L).ofType(Number.class);\r\n\r\n// (tuple(1, 1), tuple(2, 2), tuple(null, 3))\r\nSeq.of(1, 2, 4).rightOuterJoin(Seq.of(1, 2, 3), (a, b) -\u003e a == b);\r\n\r\n// (tuple(NULL, tuple(1, 0)), tuple(tuple(1, 0), tuple(2, 1)))\r\nSeq.of(tuple(1, 0), tuple(2, 1)).rightOuterSelfJoin((t, u) -\u003e t.v1 == u.v2)\r\n\r\n// tuple((1, 3), (2, 4))\r\nSeq.of(1, 2, 3, 4).partition(i -\u003e i % 2 != 0);\r\n\r\n// (1, 3, 4)\r\nSeq.of(1, 2, 3, 4).remove(2);\r\n\r\n// (1, 4)\r\nSeq.of(1, 2, 3, 4).removeAll(2, 3, 5);\r\n\r\n// (2, 3)\r\nSeq.of(1, 2, 3, 4).retainAll(2, 3, 5);\r\n\r\n// (4, 3, 2, 1)\r\nSeq.of(1, 2, 3, 4).reverse();\r\n\r\n// (3, 1, 4, 5, 2) for example\r\nSeq.of(1, 2, 3, 4, 5).shuffle();\r\n\r\n// (3, 4, 5)\r\nSeq.of(1, 2, 3, 4, 5).skipWhile(i -\u003e i \u003c 3);\r\n\r\n// (3, 4, 5)\r\nSeq.of(1, 2, 3, 4, 5).skipUntil(i -\u003e i == 3);\r\n\r\n// (2, 3)\r\nSeq.of(1, 2, 3, 4, 5).slice(1, 3)\r\n\r\n// tuple((1, 2), (3, 4, 5))\r\nSeq.of(1, 2, 3, 4, 5).splitAt(2);\r\n\r\n// tuple(1, (2, 3, 4, 5))\r\nSeq.of(1, 2, 3, 4, 5).splitAtHead();\r\n\r\n// tuple((1, 2, 3), (a, b, c))\r\nSeq.unzip(Seq.of(tuple(1, \"a\"), tuple(2, \"b\"), tuple(3, \"c\")));\r\n\r\n// (tuple(1, \"a\"), tuple(2, \"b\"), tuple(3, \"c\"))\r\nSeq.of(1, 2, 3).zip(Seq.of(\"a\", \"b\", \"c\"));\r\n\r\n// (\"1:a\", \"2:b\", \"3:c\")\r\nSeq.of(1, 2, 3).zip(Seq.of(\"a\", \"b\", \"c\"), (x, y) -\u003e x + \":\" + y);\r\n\r\n// (tuple(\"a\", 0), tuple(\"b\", 1), tuple(\"c\", 2))\r\nSeq.of(\"a\", \"b\", \"c\").zipWithIndex();\r\n```\r\n\r\norg.jooq.lambda.Unchecked\r\n-------------------------\r\n\r\nLambda expressions and checked exceptions are a major pain. Even before going live with Java 8, there are a lot of Stack Overflow questions related to the subject:\r\n\r\n- http://stackoverflow.com/q/18198176/521799\r\n- http://stackoverflow.com/q/19757300/521799\r\n- http://stackoverflow.com/q/14039995/521799\r\n\r\nThe Unchecked class can be used to wrap common `@FunctionalInterfaces` in equivalent ones that are allowed to throw checked exceptions. E.g. this painful beast:\r\n\r\n```java\r\nArrays.stream(dir.listFiles()).forEach(file -\u003e {\r\n    try {\r\n        System.out.println(file.getCanonicalPath());\r\n    }\r\n    catch (IOException e) {\r\n        throw new RuntimeException(e);\r\n    }\r\n\r\n    // Ouch, my fingers hurt! All this typing!\r\n});\r\n```\r\n\r\n... will become this beauty:\r\n\r\n```java\r\nArrays.stream(dir.listFiles()).forEach(\r\n    Unchecked.consumer(file -\u003e { System.out.println(file.getCanonicalPath()); })\r\n);\r\n```\r\n\r\n... or if you fancy method references:\r\n\r\n```java\r\nArrays.stream(dir.listFiles())\r\n        .map(Unchecked.function(File::getCanonicalPath))\r\n        .forEach(System.out::println);\r\n```\r\n\r\nDo note that `Unchecked` also allows you to throw checked exceptions explicitly without the compiler noticing:\r\n\r\n```java\r\n// Compiler doesn't see that checked Exception is being thrown:\r\nUnchecked.throwChecked(new Exception());\r\n```\r\n\r\nDownload\r\n--------\r\n\r\n**For use with Java 9+**\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n  \u003cgroupId\u003eorg.jooq\u003c/groupId\u003e\r\n  \u003cartifactId\u003ejool\u003c/artifactId\u003e\r\n  \u003cversion\u003e0.9.15\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\n**For use with Java 8+**\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n  \u003cgroupId\u003eorg.jooq\u003c/groupId\u003e\r\n  \u003cartifactId\u003ejool-java-8\u003c/artifactId\u003e\r\n  \u003cversion\u003e0.9.15\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n","funding_links":[],"categories":["Projects","Java","项目","I. Development","Memory and concurrency","Technologies we used in the Microservices","Functional libraries","Functional Programming","Solutions"],"sub_categories":["Functional Programming","函数式编程","6. Useful libraries","Core Java Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjOOQ%2FjOOL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FjOOQ%2FjOOL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjOOQ%2FjOOL/lists"}