{"id":15050648,"url":"https://github.com/jozic/scalaj","last_synced_at":"2025-04-10T02:19:26.276Z","repository":{"id":25929886,"uuid":"29371163","full_name":"jozic/scalaj","owner":"jozic","description":"scala/java interoperability, as deep as you want","archived":false,"fork":false,"pushed_at":"2023-06-11T18:19:57.000Z","size":128,"stargazers_count":23,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T03:44:14.486Z","etag":null,"topics":["java","nested-collections","primitives","scala","scalaj-converters"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jozic.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-16T22:39:29.000Z","updated_at":"2023-12-28T00:25:52.000Z","dependencies_parsed_at":"2025-02-16T10:42:26.780Z","dependency_job_id":null,"html_url":"https://github.com/jozic/scalaj","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozic%2Fscalaj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozic%2Fscalaj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozic%2Fscalaj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozic%2Fscalaj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jozic","download_url":"https://codeload.github.com/jozic/scalaj/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142906,"owners_count":21054672,"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":["java","nested-collections","primitives","scala","scalaj-converters"],"created_at":"2024-09-24T21:28:40.980Z","updated_at":"2025-04-10T02:19:26.244Z","avatar_url":"https://github.com/jozic.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"ScalaJ Converters [![Build Status](https://github.com/jozic/scalaj/actions/workflows/checks.yml/badge.svg?branch=main)](https://github.com/jozic/scalaj/actions/workflows/checks.yml) [![Coverage Status](https://coveralls.io/repos/jozic/scalaj/badge.svg)](https://coveralls.io/r/jozic/scalaj)\n=================\n\n### When JavaConverters is not enough...\n\nIf you work on a Java/Scala mixed project you can find yourself converting\njava collections and/or primitive wrappers to/from corresponding scala classes or vice versa.\nJavaConverters is your friend here, but it's not always good enough.\n\nIf you are tired of doing something like this\n\n```scala\nimport scala.jdk.CollectionConverters._\n\ndef iTakeInt(i: Int) = { ... }\n\nval something = someJavaListOfJavaIntegers.asScala.map(iTakeInt(_))\n```\n\nor this\n\n```scala\nimport scala.jdk.CollectionConverters._\n\nval something: mutable.Map[java.lang.Long, Buffer] = \n  someJavaMapOfJavaLongsToJavaLists.asScala.mapValues(_.asScala)\n```\n\nlook no more!  \nNow you can do\n\n```scala\nimport com.daodecode.scalaj.collection._\n\ndef iTakeInt(i: Int) = { ... }\n\nval something = someJavaListOfJavaIntegers.deepAsScala.map(iTakeInt)\n```\n\nand \n\n```scala\nimport com.daodecode.scalaj.collection._\n\nval something: mutable.Map[Long, Buffer] = \n  someJavaMapOfJavaLongsToJavaLists.deepAsScala\n```\n\nScalaJ Converters will go all the way down converting every nested collection or primitive type.  \nOf course you should be ready to pay some cost for all these conversions.\n\nImport `import com.daodecode.scalaj.collection._` aslo brings standard `JavaConverters._` in scope, \nso you can use plain `asJava/asScala` if you don't have nested collections or collections of primitives.\n\nHaving `scalaj-googloptional` in classpath you can add [guava Optionals](https://github.com/google/guava/blob/master/guava/src/com/google/common/base/Optional.java) to your\nfunky data structures and convert between them and scala versions all the way down and back.\n\n```scala\nval foo: java.util.Set[Optional[java.lang.Double] = ...\n\nimport com.daodecode.scalaj.googleoptional._\n\nval scalaFoo: mutable.Set[Option[Double]] = foo.deepAsScala\n```\n\nIf you want you scala collections ~~well-done~~ immutable, you can do it as well\n\n```scala\nval boo: java.util.Set[Optional[java.util.List[java.lang.Double]] = ...\n\nimport com.daodecode.scalaj.googleoptional._\nimport com.daodecode.scalaj.collection.immutable._\n\nval immutableScalaBoo: Set[Option[immutable.Seq[Double]]] = boo.deepAsScalaImmutable\n```\n\n\n# Latest stable release\n\n## scalaj-collection\n\n| 2.10                                                                                                                                                                                                       | 2.11                                                                                                                                                                                                       | 2.12                                                                                                                                                                                                       | 2.13                                                                                                                                                                                                       | 3                                                                                                                                                                                                    |\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-collection_2.10/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-collection_2.10) | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-collection_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-collection_2.11) | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-collection_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-collection_2.12) | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-collection_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-collection_2.13) | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-collection_3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-collection_3) |\n\n### sbt\n```scala\nlibraryDependencies += \"com.daodecode\" %% \"scalaj-collection\" % \"0.3.2\"\n```\n### maven\n\nset `\u003cscala.binary.version\u003e` property to scala version you need, like\n\n```xml\n\u003cproperties\u003e\n    \u003cscala.binary.version\u003e2.13\u003c/scala.binary.version\u003e\n\u003c/properties\u003e\n```\n\n and then in `dependencies` add\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.daodecode\u003c/groupId\u003e\n    \u003cartifactId\u003escalaj-collection_${scala.binary.version}\u003c/artifactId\u003e\n    \u003cversion\u003e0.3.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## scalaj-googleoptional\n\n| 2.10                                                                                                                                                                                                               | 2.11                                                                                                                                                                                                               | 2.12                                                                                                                                                                                                               | 2.13                                                                                                                                                                                                               | 3                                                                                                                                                                                                            |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-googleoptional_2.10/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-googleoptional_2.10) | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-googleoptional_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-googleoptional_2.11) | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-googleoptional_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-googleoptional_2.12) | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-googleoptional_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-googleoptional_2.13) | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-googleoptional_3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.daodecode/scalaj-googleoptional_3) |\n\n### sbt\n\n```scala\nlibraryDependencies += \"com.daodecode\" %% \"scalaj-googleoptional\" % \"0.3.2\"\n```\n### maven\n\n```xml\n\u003cproperties\u003e\n    \u003cscala.binary.version\u003e2.13\u003c/scala.binary.version\u003e\n\u003c/properties\u003e\n```\n\n and then in `dependencies` add\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.daodecode\u003c/groupId\u003e\n    \u003cartifactId\u003escalaj-googleoptional_${scala.binary.version}\u003c/artifactId\u003e\n    \u003cversion\u003e0.3.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n# Latest snapshot\n\nFirst add sonatype snapshots repository to your settings\n\n### sbt\n\n```scala\nresolvers += Resolver.sonatypeRepo(\"snapshots\")\n```\n\n### maven\n\n```xml\n\u003crepository\u003e\n    \u003cid\u003esnapshots-repo\u003c/id\u003e\n    \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n    \u003creleases\u003e\u003cenabled\u003efalse\u003c/enabled\u003e\u003c/releases\u003e\n    \u003csnapshots\u003e\u003cenabled\u003etrue\u003c/enabled\u003e\u003c/snapshots\u003e\n\u003c/repository\u003e\n```\n\nthen add snapshot as a dependency\n\n## scalaj-collection\n\n### sbt\n\n```scala\nlibraryDependencies += \"com.daodecode\" %% \"scalaj-collection\" % \"0.3.3-SNAPSHOT\"\n```\n\n### maven\n\n```xml\n\u003cproperties\u003e\n    \u003cscala.binary.version\u003e2.13\u003c/scala.binary.version\u003e\n\u003c/properties\u003e\n```\n\n and then in `dependencies` add\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.daodecode\u003c/groupId\u003e\n    \u003cartifactId\u003escalaj-collection_${scala.binary.version}\u003c/artifactId\u003e\n    \u003cversion\u003e0.3.3-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## scalaj-googleoptional\n\n### sbt\n\n```scala\nlibraryDependencies += \"com.daodecode\" %% \"scalaj-googleoptional\" % \"0.3.3-SNAPSHOT\"\n```\n### maven\n\n```xml\n\u003cproperties\u003e\n    \u003cscala.binary.version\u003e2.13\u003c/scala.binary.version\u003e\n\u003c/properties\u003e\n```\n\n and then in `dependencies` add\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.daodecode\u003c/groupId\u003e\n    \u003cartifactId\u003escalaj-googleoptional_${scala.binary.version}\u003c/artifactId\u003e\n    \u003cversion\u003e0.3.3-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n# Related projects\n\nhttps://github.com/softprops/guavapants  \n\nhttps://github.com/scalaj/scalaj-collection\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjozic%2Fscalaj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjozic%2Fscalaj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjozic%2Fscalaj/lists"}