public abstract class JavaPartialFunction<A,B>
extends scala.runtime.AbstractPartialFunction<A,B>
isCheck == true
and the latter to isCheck == false
for those cases where
this is important to know.
Failure to match is signaled by throwing noMatch()
, i.e. not returning
normally (the exception used in this case is pre-allocated, hence not
that expensive).
new JavaPartialFunction<Object, String>() {
public String apply(Object in, boolean isCheck) {
if (in instanceof TheThing) {
if (isCheck) return null; // to spare the expensive or side-effecting code
return doSomethingWithTheThing((TheThing) in);
} else {
throw noMatch();
}
}
}
The typical use of partial functions from Akka looks like the following:
if (pf.isDefinedAt(x)) {
pf.apply(x);
}
i.e. it will first call JavaPartialFunction.apply(x, true)
and if that
does not throw noMatch()
it will continue with calling
JavaPartialFunction.apply(x, false)
.
Modifier and Type | Class and Description |
---|---|
static class |
JavaPartialFunction.NoMatch$ |
static class |
JavaPartialFunction.NoMatchException |
Constructor and Description |
---|
JavaPartialFunction() |
Modifier and Type | Method and Description |
---|---|
static <C> scala.PartialFunction<A,C> |
andThen(scala.Function1<B,C> k) |
B |
apply(A x) |
abstract B |
apply(A x,
boolean isCheck) |
static double |
apply$mcDD$sp(double x) |
static double |
apply$mcDF$sp(float x) |
static double |
apply$mcDI$sp(int x) |
static double |
apply$mcDJ$sp(long x) |
static float |
apply$mcFD$sp(double x) |
static float |
apply$mcFF$sp(float x) |
static float |
apply$mcFI$sp(int x) |
static float |
apply$mcFJ$sp(long x) |
static int |
apply$mcID$sp(double x) |
static int |
apply$mcIF$sp(float x) |
static int |
apply$mcII$sp(int x) |
static int |
apply$mcIJ$sp(long x) |
static long |
apply$mcJD$sp(double x) |
static long |
apply$mcJF$sp(float x) |
static long |
apply$mcJI$sp(int x) |
static long |
apply$mcJJ$sp(long x) |
static void |
apply$mcVD$sp(double x) |
static void |
apply$mcVF$sp(float x) |
static void |
apply$mcVI$sp(int x) |
static void |
apply$mcVJ$sp(long x) |
static boolean |
apply$mcZD$sp(double x) |
static boolean |
apply$mcZF$sp(float x) |
static boolean |
apply$mcZI$sp(int x) |
static boolean |
apply$mcZJ$sp(long x) |
<A1 extends A,B1> |
applyOrElse(A1 x,
scala.Function1<A1,B1> default_) |
static <A> scala.Function1<A,R> |
compose(scala.Function1<A,T1> g) |
boolean |
isDefinedAt(A x) |
static scala.Function1<A,scala.Option<B>> |
lift() |
static java.lang.RuntimeException |
noMatch() |
static <A1 extends A,B1> |
orElse(scala.PartialFunction<A1,B1> that) |
static <U> scala.Function1<A,java.lang.Object> |
runWith(scala.Function1<B,U> action) |
static java.lang.String |
toString() |
andThen, apply$mcDD$sp, apply$mcDF$sp, apply$mcDI$sp, apply$mcDJ$sp, apply$mcFD$sp, apply$mcFF$sp, apply$mcFI$sp, apply$mcFJ$sp, apply$mcID$sp, apply$mcIF$sp, apply$mcII$sp, apply$mcIJ$sp, apply$mcJD$sp, apply$mcJF$sp, apply$mcJI$sp, apply$mcJJ$sp, apply$mcVD$sp, apply$mcVF$sp, apply$mcVI$sp, apply$mcVJ$sp, apply$mcZD$sp, apply$mcZF$sp, apply$mcZI$sp, apply$mcZJ$sp, compose, lift, orElse, runWith, toString
public static final java.lang.RuntimeException noMatch()
public static <A> scala.Function1<A,R> compose(scala.Function1<A,T1> g)
public static java.lang.String toString()
public static <A1 extends A,B1> scala.PartialFunction<A1,B1> orElse(scala.PartialFunction<A1,B1> that)
public static <C> scala.PartialFunction<A,C> andThen(scala.Function1<B,C> k)
public static scala.Function1<A,scala.Option<B>> lift()
public static <U> scala.Function1<A,java.lang.Object> runWith(scala.Function1<B,U> action)
public static boolean apply$mcZD$sp(double x)
public static double apply$mcDD$sp(double x)
public static float apply$mcFD$sp(double x)
public static int apply$mcID$sp(double x)
public static long apply$mcJD$sp(double x)
public static void apply$mcVD$sp(double x)
public static boolean apply$mcZF$sp(float x)
public static double apply$mcDF$sp(float x)
public static float apply$mcFF$sp(float x)
public static int apply$mcIF$sp(float x)
public static long apply$mcJF$sp(float x)
public static void apply$mcVF$sp(float x)
public static boolean apply$mcZI$sp(int x)
public static double apply$mcDI$sp(int x)
public static float apply$mcFI$sp(int x)
public static int apply$mcII$sp(int x)
public static long apply$mcJI$sp(int x)
public static void apply$mcVI$sp(int x)
public static boolean apply$mcZJ$sp(long x)
public static double apply$mcDJ$sp(long x)
public static float apply$mcFJ$sp(long x)
public static int apply$mcIJ$sp(long x)
public static long apply$mcJJ$sp(long x)
public static void apply$mcVJ$sp(long x)
public abstract B apply(A x, boolean isCheck) throws java.lang.Exception
java.lang.Exception
public final boolean isDefinedAt(A x)