Package org.apache.pekko.japi.pf
Class PFBuilder<I,R>
java.lang.Object
org.apache.pekko.japi.pf.PFBuilder<I,R>
- Type Parameters:
I
- the input type, that this PartialFunction will be applied toR
- the return type, that the results of the application will have
A builder for
PartialFunction
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addStatement
(scala.PartialFunction<I, R> statement) build()
Build aPartialFunction
from this builder.static <I,
R> PFBuilder<I, R> create()
Create a newPFBuilder
.Add a new case statement to this builder.Add a new case statement to this builder.Add a new case statement to this builder, that matches any argument.matchEquals
(P object, Function<P, R> apply) Add a new case statement to this builder.matchUnchecked
(Class<?> type, Function<?, R> apply) Add a new case statement to this builder without compile time type check of the parameters.matchUnchecked
(Class<?> type, Predicate<?> predicate, Function<?, R> apply) Add a new case statement to this builder without compile time type check of the parameters.
-
Field Details
-
statements
-
-
Constructor Details
-
PFBuilder
public PFBuilder()Create a PFBuilder.
-
-
Method Details
-
create
Create a newPFBuilder
.- Since:
- 1.1.0
-
match
Add a new case statement to this builder.- 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
-
matchUnchecked
Add a new case statement to this builder without compile time type check of the parameters. Should normally not be used, but when matching on class with generic type argument it can be useful, e.g.List.class
and(List<String> list) -> {}
.- 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
Add a new case statement to this builder.- 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
-
matchUnchecked
Add a new case statement to this builder without compile time type check of the parameters. Should normally not be used, but when matching on class with generic type argument it can be useful, e.g.List.class
and(List<String> list) -> {}
.- 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
-
matchEquals
Add a new case statement to this builder.- Parameters:
object
- the object to compare equals withapply
- an action to apply to the argument if the object compares equal- Returns:
- a builder with the case statement added
-
matchAny
Add a new case statement to this builder, that matches any argument.- Parameters:
apply
- an action to apply to the argument- Returns:
- a builder with the case statement added
-
addStatement
-
build
Build aPartialFunction
from this builder. After this call the builder will be reset.- Returns:
- a PartialFunction for this builder.
-