Created
May 8, 2017 16:06
-
-
Save m4tx/ca0958cf1fea21b55bae600a72eb58d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils; | |
import scala.Tuple2; | |
import scala.collection.JavaConversions; | |
import scala.collection.Seq; | |
import java.util.Map; | |
import java.util.Set; | |
import java.util.stream.Collectors; | |
public class ScalaConverters { | |
public static <A, B> Seq<Tuple2<A, B>> mapToEntrySeq(Map<A, B> map) { | |
Set<Tuple2<A, B>> set = map | |
.entrySet() | |
.stream() | |
.map(x -> new Tuple2<>(x.getKey(), x.getValue())) | |
.collect(Collectors.toSet()); | |
return JavaConversions.asScalaSet(set).toSeq(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment