{"id":16465031,"url":"https://github.com/ajoberstar/cljj","last_synced_at":"2025-12-12T01:12:03.493Z","repository":{"id":35593387,"uuid":"39866268","full_name":"ajoberstar/cljj","owner":"ajoberstar","description":"Clojure to Java Interop APIs","archived":false,"fork":false,"pushed_at":"2022-08-13T20:17:04.000Z","size":208,"stargazers_count":79,"open_issues_count":2,"forks_count":4,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-15T00:39:34.072Z","etag":null,"topics":["clojure","java"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajoberstar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-29T01:23:11.000Z","updated_at":"2024-05-31T07:49:13.000Z","dependencies_parsed_at":"2022-08-27T00:11:05.683Z","dependency_job_id":null,"html_url":"https://github.com/ajoberstar/cljj","commit_stats":null,"previous_names":["ajoberstar/ike.cljj"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajoberstar%2Fcljj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajoberstar%2Fcljj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajoberstar%2Fcljj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajoberstar%2Fcljj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajoberstar","download_url":"https://codeload.github.com/ajoberstar/cljj/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243667965,"owners_count":20328036,"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":["clojure","java"],"created_at":"2024-10-11T11:31:41.083Z","updated_at":"2025-12-12T01:12:03.418Z","avatar_url":"https://github.com/ajoberstar.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cljj\n\n[![Clojars](https://img.shields.io/clojars/v/org.ajoberstar/cljj.svg?style=flat-square)](http://clojars.org/org.ajoberstar/cljj)\n[![cljdoc badge](https://cljdoc.org/badge/org.ajoberstar/cljj)](https://cljdoc.org/d/org.ajoberstar/cljj)\n![CI](https://github.com/ajoberstar/cljj/workflows/CI/badge.svg)\n\n**DISCLAIMER:** Prior to 0.5.0, this library was `org.ajoberstar/ike.cljj` with namespaces under `ike.cljj.*`. It is now `org.ajoberstar/cljj` with namespaces under `org.ajoberstar.cljj`.\n\n## Why do you care?\n\nClojure provides some nice Java interop features, but they are missing clean support for newer APIs added to\nJava 7+.\n\n## What is it?\n\ncljj is a Clojure library of wrappers around Java APIs.\n\n### Current Support\n\n* Clojure functions to arbitrary Single Abstract Method (SAM) types (`org.ajoberstar.cljj.function` -\u003e `java.util.function` and others)\n* Streams (`org.ajoberstar.cljj.stream` -\u003e `java.util.stream`)\n* NIO2 File API (`org.ajoberstar.cljj.file` -\u003e `java.nio.file`)\n\n## Usage\n\n**NOTE:** cljj requires Java 8+\n\n* [Release Notes](https://github.com/ajoberstar/cljj/releases)\n\n### Reducing on a Stream\n\nRequiring the `org.ajoberstar.cljj.stream` namespace will add support for two main things:\n\n- Turning a Stream into an ISeq with `stream-seq`.\n- Reducing/Transducing/etc over a Stream (due to `CollReduce` impl)\n\n```clojure\n(let [stream (IntStream/range 0 10)]\n  (= 25 (transduce (filter odd?) + stream))))\n```\n\n### Converting Clojure functions to Java SAMs\n\nAs of Java 8, there is powerful support in the Java language for lambdas and\nmethod references. One of these features is that methods that accept an argument\nwhich is a Single Abstract Method (SAM) interface can also accept any method reference\nor lambda of the same shape/type.\n\nThis unforunately does not translate to Clojure users.\n\nThe `org.ajoberstar.cljj.function` namespace includes three main helpers for this:\n\n* `sam*` - function converting a Clojure function to an arbitrary SAM interface\n* `sam` - creating an anonymous SAM impl, as it were a Clojure function\n* `defsam` - defining a named SAM impl, as if it were a Clojure function\n\n**WARNING:** You may need type hints to avoid `IllegalAccessError` in Java 9+.\n\n```clojure\n(defsam my-sam\n  java.util.function.Predicate\n  [x]\n  (= x \"it matched\"))\n\n;; ignore that I'm not using org.ajoberstar.cljj.stream here\n(-\u003e (Stream/of \"not a match\" \"it matched\")\n    (.filter my-sam)\n    (.collect Collectors/toList)\n```\n\nNote that primitive streams require different SAM types.\n\n```clojure\n;; ignore that I'm not using org.ajoberstar.cljj.stream here\n(-\u003e (IntStream/range 0 10)\n    (.filter (sam* java.util.function.IntPredicate odd?))\n    (.collect Collectors/toList)\n```\n\n### File API\n\nThe NIO2 API for files is much improved over `java.io.File`, but has some headaches from\nClojure, namely the extensive use of varargs. The `org.ajoberstar.cljj.file` namespace provides wrappers\nover these functions for two benefits:\n\n- more natural variadic functions for Clojure use (no explicit `into-array` calls)\n- flexible argument types using the `Pathish` protocol that already converts many common types\nto `Path` (e.g. `String`, `File`, `URI`).\n\n## Questions, Bugs, and Features\n\nPlease use the repo's [issues](https://github.com/ajoberstar/cljj/issues)\nfor all questions, bug reports, and feature requests.\n\n## Contributing\n\nContributions are very welcome and are accepted through pull requests.\n\nSmaller changes can come directly as a PR, but larger or more complex\nones should be discussed in an issue first to flesh out the approach.\n\nIf you're interested in implementing a feature on the\n[issues backlog](https://github.com/ajoberstar/cljj/issues), add a comment\nto make sure it's not already in progress and for any needed discussion.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajoberstar%2Fcljj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajoberstar%2Fcljj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajoberstar%2Fcljj/lists"}