org.apache.pekko.japi

Members list

Type members

Classlikes

Attributes

Companion
class
Source
JavaAPI.scala
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class JavaPartialFunction[A, B] extends AbstractPartialFunction[A, B]

Helper for implementing a pure partial function: it will possibly be invoked multiple times for a single “application”, because its only abstract method is used for both isDefinedAt() and apply(); the former is mapped to isCheck == true and the latter to isCheck == false for those cases where this is important to know.

Helper for implementing a pure partial function: it will possibly be invoked multiple times for a single “application”, because its only abstract method is used for both isDefinedAt() and apply(); the former is mapped to 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 Apache Pekko 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).

Attributes

Companion
object
Source
JavaAPI.scala
Supertypes
trait PartialFunction[A, B]
trait A => B
class Object
trait Matchable
class Any
Show all
case class Pair[A, B](first: A, second: B)

Java API Represents a pair (tuple) of two elements.

Java API Represents a pair (tuple) of two elements.

Additional tuple types for 3 to 22 values are defined in the org.apache.pekko.japi.tuple package, e.g. pekko.japi.tuple.Tuple3.

Attributes

Companion
object
Source
JavaAPI.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Pair

Attributes

Companion
class
Source
JavaAPI.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Pair.type
object Throwables

Helper class for determining whether a Throwable is fatal or not. User should only catch the non-fatal one,and keep rethrow the fatal one.

Helper class for determining whether a Throwable is fatal or not. User should only catch the non-fatal one,and keep rethrow the fatal one.

Fatal errors are errors like VirtualMachineError (for example, OutOfMemoryError and StackOverflowError, subclasses of VirtualMachineError), ThreadDeath, LinkageError, InterruptedException, ControlThrowable.

Note. this helper keep the same semantic with NonFatal in Scala. For example, all harmless Throwables can be caught by:

 try {
   // dangerous stuff
 } catch(Throwable e) {
   if (Throwables.isNonFatal(e)){
     log.error(e, "Something not that bad.");
   } else {
     throw e;
   }

Attributes

Source
Throwables.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Throwables.type
object Util

This class hold common utilities for Java

This class hold common utilities for Java

Attributes

Source
JavaAPI.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Util.type