public class Scala
extends java.lang.Object
Constructor and Description |
---|
Scala() |
Modifier and Type | Method and Description |
---|---|
static <T> T[] |
asArray(java.lang.Class<T> clazz,
scala.collection.Seq<T> scalaList)
Converts a Scala List to an Array.
|
static <K,V> java.util.Map<K,V> |
asJava(scala.collection.Map<K,V> scalaMap)
Converts a Scala Map to Java.
|
static <T> java.util.List<T> |
asJava(scala.collection.Seq<T> scalaList)
Converts a Scala List to Java.
|
static <A,B> F.Tuple<A,B> |
asJava(scala.Tuple2<A,B> tuple)
Converts a scala
Tuple2 to a java F.Tuple. |
static <A> scala.Function0<A> |
asScala(java.util.concurrent.Callable<A> callable)
Converts a Java Callable to a Scala Function0.
|
static <A> scala.collection.immutable.Seq<A> |
asScala(java.util.Collection<A> javaCollection)
Converts a Java Collection to a Scala Seq.
|
static <K,V> scala.collection.immutable.Map<K,V> |
asScala(java.util.Map<K,V> javaMap)
Converts a Java Map to Scala.
|
static <A> scala.Function0<scala.concurrent.Future<A>> |
asScalaWithFuture(java.util.concurrent.Callable<java.util.concurrent.CompletionStage<A>> callable)
Converts a Java Callable to a Scala Function0.
|
static <C> scala.reflect.ClassTag<C> |
classTag() |
static <A,B> scala.collection.immutable.Map<A,B> |
emptyMap() |
static <T> scala.collection.Seq<T> |
emptySeq() |
static java.lang.RuntimeException |
noMatch()
Throw this exception to indicate that a partial function doesn't match.
|
static <T> scala.Option<T> |
None() |
static <T> scala.Option<T> |
Option(T t)
Wrap a value into a Scala Option.
|
static <T> T |
orElse(scala.Option<T> opt,
T defaultValue)
Wraps a Scala Option, handling None by returning a defaultValue
|
static <T> T |
orNull(scala.Option<T> opt)
Wraps a Scala Option, handling None as null.
|
static <A,B> scala.PartialFunction<A,B> |
partialFunction(java.util.function.Function<A,B> f)
Create a Scala PartialFunction from a function.
|
static <T> scala.collection.Seq<T> |
toSeq(java.util.List<T> list)
Converts a Java List to Scala Seq.
|
static <T> scala.collection.Seq<T> |
toSeq(T[] array)
Converts a Java Array to Scala Seq.
|
static <A,B> scala.Tuple2<A,B> |
Tuple(A a,
B b)
Creates a Scala
Tuple2 . |
static <T> scala.collection.Seq<T> |
varargs(T... array)
Converts a Java varargs to Scala Seq.
|
public static <T> T orNull(scala.Option<T> opt)
T
- the type in the Option.opt
- the scala option.public static <T> T orElse(scala.Option<T> opt, T defaultValue)
T
- the type in the Option.opt
- the scala option.defaultValue
- the default value if None is found.public static <K,V> java.util.Map<K,V> asJava(scala.collection.Map<K,V> scalaMap)
K
- key typeV
- value typescalaMap
- the scala map.public static <K,V> scala.collection.immutable.Map<K,V> asScala(java.util.Map<K,V> javaMap)
K
- key typeV
- value typejavaMap
- the java mappublic static <A> scala.collection.immutable.Seq<A> asScala(java.util.Collection<A> javaCollection)
A
- the type of Seq elementjavaCollection
- the java collectionpublic static <A> scala.Function0<A> asScala(java.util.concurrent.Callable<A> callable)
A
- the return type.callable
- the java callable.public static <A> scala.Function0<scala.concurrent.Future<A>> asScalaWithFuture(java.util.concurrent.Callable<java.util.concurrent.CompletionStage<A>> callable)
A
- the return type.callable
- the java callable.public static <T> java.util.List<T> asJava(scala.collection.Seq<T> scalaList)
T
- the return type.scalaList
- the scala list.public static <T> T[] asArray(java.lang.Class<T> clazz, scala.collection.Seq<T> scalaList)
T
- the return type.clazz
- the element class typescalaList
- the scala list.public static <T> scala.Option<T> Option(T t)
T
- the element type.t
- the java value.public static <T> scala.Option<T> None()
T
- the type parameterNone
.public static <A,B> scala.Tuple2<A,B> Tuple(A a, B b)
Tuple2
.A
- input parameter typeB
- return type.a
- element one of the tuple.b
- element two of the tuple.public static <A,B> F.Tuple<A,B> asJava(scala.Tuple2<A,B> tuple)
Tuple2
to a java F.Tuple.A
- input parameter typeB
- return type.tuple
- the Scala Tuple.public static <T> scala.collection.Seq<T> emptySeq()
T
- the type parameterpublic static <A,B> scala.collection.immutable.Map<A,B> emptyMap()
A
- input parameter typeB
- return type.public static <C> scala.reflect.ClassTag<C> classTag()
C
- the classtag's type.public static <A,B> scala.PartialFunction<A,B> partialFunction(java.util.function.Function<A,B> f)
F.noMatch()
, and this will be translated into the semantics
of a Scala PartialFunction.
For example:
Flow<String, Integer, ?> collectInts = Flow.<String>collect(Scala.partialFunction( str -> { try { return Integer.parseInt(str); } catch (NumberFormatException e) { throw Scala.noMatch(); } }));The above code will convert a flow of String into a flow of Integer, dropping any strings that can't be parsed as integers.
A
- input parameter typeB
- return type.f
- The function to make a partial function from.public static java.lang.RuntimeException noMatch()
public static <T> scala.collection.Seq<T> toSeq(java.util.List<T> list)
T
- the element type.list
- the java list.public static <T> scala.collection.Seq<T> toSeq(T[] array)
T
- the element type.array
- the java array.@SafeVarargs public static <T> scala.collection.Seq<T> varargs(T... array)
T
- the element type.array
- the java array.