Package akka.japi.pf
Class DeciderBuilder
- java.lang.Object
-
- akka.japi.pf.DeciderBuilder
-
public class DeciderBuilder extends java.lang.Object
Used for building a partial function forActor.supervisorStrategy()
. * Inside an actor you can use it like this with Java 8 to define your supervisorStrategy.Example:
@Override private static SupervisorStrategy strategy = new OneForOneStrategy(10, Duration.ofMinutes(1), DeciderBuilder. match(ArithmeticException.class, e -> resume()). match(NullPointerException.class, e -> restart()). match(IllegalArgumentException.class, e -> stop()). matchAny(o -> escalate()).build()); @Override public SupervisorStrategy supervisorStrategy() { return strategy; }
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <P extends java.lang.Throwable>
PFBuilder<java.lang.Throwable,SupervisorStrategy.Directive>match(java.lang.Class<P> type, FI.Apply<P,SupervisorStrategy.Directive> apply)
Return a newPFBuilder
with a case statement added.static <P extends java.lang.Throwable>
PFBuilder<java.lang.Throwable,SupervisorStrategy.Directive>match(java.lang.Class<P> type, FI.TypedPredicate<P> predicate, FI.Apply<P,SupervisorStrategy.Directive> apply)
Return a newPFBuilder
with a case statement added.static PFBuilder<java.lang.Throwable,SupervisorStrategy.Directive>
matchAny(FI.Apply<java.lang.Throwable,SupervisorStrategy.Directive> apply)
Return a newPFBuilder
with a case statement added.
-
-
-
Method Detail
-
match
public static <P extends java.lang.Throwable> PFBuilder<java.lang.Throwable,SupervisorStrategy.Directive> match(java.lang.Class<P> type, FI.Apply<P,SupervisorStrategy.Directive> apply)
Return a newPFBuilder
with a case statement added.- Parameters:
type
- a type to match the argument againstapply
- an action to apply to the argument if the type matches- Returns:
- a builder with the case statement added
-
match
public static <P extends java.lang.Throwable> PFBuilder<java.lang.Throwable,SupervisorStrategy.Directive> match(java.lang.Class<P> type, FI.TypedPredicate<P> predicate, FI.Apply<P,SupervisorStrategy.Directive> apply)
Return a newPFBuilder
with a case statement added.- Parameters:
type
- a type to match the argument againstpredicate
- a predicate that will be evaluated on the argument if the type matchesapply
- an action to apply to the argument if the type matches and the predicate returns true- Returns:
- a builder with the case statement added
-
matchAny
public static PFBuilder<java.lang.Throwable,SupervisorStrategy.Directive> matchAny(FI.Apply<java.lang.Throwable,SupervisorStrategy.Directive> apply)
Return a newPFBuilder
with a case statement added.- Parameters:
apply
- an action to apply to the argument- Returns:
- a builder with the case statement added
-
-