All Projects → jozic → scalaj

jozic / scalaj

Licence: BSD-3-Clause license
scala/java interoperability, as deep as you want

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to scalaj

ArrayInterface.jl
Designs for new Base array interface primitives, used widely through scientific machine learning (SciML) and other organizations
Stars: ✭ 111 (+455%)
Mutual labels:  primitives
geometrize-haxe-demo
Demo using Geometrize Haxe and HaxeFlixel to recreate images with geometric primitives
Stars: ✭ 17 (-15%)
Mutual labels:  primitives
primitives
Foundational components for React Native UI
Stars: ✭ 38 (+90%)
Mutual labels:  primitives
frunzik
Lightweight C library for functional programming.
Stars: ✭ 28 (+40%)
Mutual labels:  primitives
alfa-ui-primitives
Alfa-Bank UI primitives for sharing between platforms
Stars: ✭ 31 (+55%)
Mutual labels:  primitives
Primitive
Reproducing images with geometric primitives.
Stars: ✭ 11,657 (+58185%)
Mutual labels:  primitives
3d Machine Learning
A resource repository for 3D machine learning
Stars: ✭ 7,405 (+36925%)
Mutual labels:  primitives
Chamfers-for-OpenSCAD
Create OpenSCAD primitives with 45° chamfers
Stars: ✭ 77 (+285%)
Mutual labels:  primitives
MLBlocks
A library for composing end-to-end tunable machine learning pipelines.
Stars: ✭ 94 (+370%)
Mutual labels:  primitives
codechain-primitives-js
JavaScript functions and classes for CodeChain primitives
Stars: ✭ 13 (-35%)
Mutual labels:  primitives

ScalaJ Converters Build Status Coverage Status

When JavaConverters is not enough...

If you work on a Java/Scala mixed project you can find yourself converting java collections and/or primitive wrappers to/from corresponding scala classes or vice versa. JavaConverters is your friend here, but it's not always good enough.

If you are tired of doing something like this

import scala.jdk.CollectionConverters._

def iTakeInt(i: Int) = { ... }

val something = someJavaListOfJavaIntegers.asScala.map(iTakeInt(_))

or this

import scala.jdk.CollectionConverters._

val something: mutable.Map[java.lang.Long, Buffer] = 
  someJavaMapOfJavaLongsToJavaLists.asScala.mapValues(_.asScala)

look no more!
Now you can do

import com.daodecode.scalaj.collection._

def iTakeInt(i: Int) = { ... }

val something = someJavaListOfJavaIntegers.deepAsScala.map(iTakeInt)

and

import com.daodecode.scalaj.collection._

val something: mutable.Map[Long, Buffer] = 
  someJavaMapOfJavaLongsToJavaLists.deepAsScala

ScalaJ Converters will go all the way down converting every nested collection or primitive type.
Of course you should be ready to pay some cost for all these conversions.

Import import com.daodecode.scalaj.collection._ aslo brings standard JavaConverters._ in scope, so you can use plain asJava/asScala if you don't have nested collections or collections of primitives.

Having scalaj-googloptional in classpath you can add guava Optionals to your funky data structures and convert between them and scala versions all the way down and back.

val foo: java.util.Set[Optional[java.lang.Double] = ...

import com.daodecode.scalaj.googleoptional._

val scalaFoo: mutable.Set[Option[Double]] = foo.deepAsScala

If you want you scala collections well-done immutable, you can do it as well

val boo: java.util.Set[Optional[java.util.List[java.lang.Double]] = ...

import com.daodecode.scalaj.googleoptional._
import com.daodecode.scalaj.collection.immutable._

val immutableScalaBoo: Set[Option[immutable.Seq[Double]]] = boo.deepAsScalaImmutable

Latest stable release

scalaj-collection

2.10 2.11 2.12 2.13
Maven Central Maven Central Maven Central Maven Central

sbt

libraryDependencies += "com.daodecode" %% "scalaj-collection" % "0.3.1"

maven

set <scala.binary.version> property to scala version you need, like

<properties>
    <scala.binary.version>2.13</scala.binary.version>
</properties>

and then in dependencies add

<dependency>
    <groupId>com.daodecode</groupId>
    <artifactId>scalaj-collection_${scala.binary.version}</artifactId>
    <version>0.3.1</version>
</dependency>

scalaj-googleoptional

2.10 2.11 2.12 2.13
Maven Central Maven Central Maven Central Maven Central

sbt

libraryDependencies += "com.daodecode" %% "scalaj-googleoptional" % "0.3.1"

maven

<properties>
    <scala.binary.version>2.13</scala.binary.version>
</properties>

and then in dependencies add

<dependency>
    <groupId>com.daodecode</groupId>
    <artifactId>scalaj-googleoptional_${scala.binary.version}</artifactId>
    <version>0.3.1</version>
</dependency>

Latest snapshot

First add sonatype snapshots repository to your settings

sbt

resolvers += Resolver.sonatypeRepo("snapshots")

maven

<repository>
    <id>snapshots-repo</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    <releases><enabled>false</enabled></releases>
    <snapshots><enabled>true</enabled></snapshots>
</repository>

then add snapshot as a dependency

scalaj-collection

sbt

libraryDependencies += "com.daodecode" %% "scalaj-collection" % "0.3.2-SNAPSHOT"

maven

<properties>
    <scala.binary.version>2.13</scala.binary.version>
</properties>

and then in dependencies add

<dependency>
    <groupId>com.daodecode</groupId>
    <artifactId>scalaj-collection_${scala.binary.version}</artifactId>
    <version>0.3.2-SNAPSHOT</version>
</dependency>

scalaj-googleoptional

sbt

libraryDependencies += "com.daodecode" %% "scalaj-googleoptional" % "0.3.2-SNAPSHOT"

maven

<properties>
    <scala.binary.version>2.13</scala.binary.version>
</properties>

and then in dependencies add

<dependency>
    <groupId>com.daodecode</groupId>
    <artifactId>scalaj-googleoptional_${scala.binary.version}</artifactId>
    <version>0.3.2-SNAPSHOT</version>
</dependency>

Related projects

https://github.com/softprops/guavapants

https://github.com/scalaj/scalaj-collection

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].