Package org.apache.pekko.japi.pf
Class Match<I,R>
java.lang.Object
org.apache.pekko.japi.pf.Match<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
Version of
PartialFunction that can be built during runtime from Java.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionasPF()Turn thisMatchinto aPartialFunction.static final <F,T> Match<F, T> Create aMatchfrom the builder.Convenience function to make the Java code more readable.static <F,T, P> PFBuilder<F, T> Convenience function to create aPFBuilderwith the first case statement added.static <F,T, P> PFBuilder<F, T> Convenience function to create aPFBuilderwith the first case statement added.static <F,T> PFBuilder<F, T> Convenience function to create aPFBuilderwith the first case statement added.static <F,T, P> PFBuilder<F, T> matchEquals(P object, Function<P, T> apply) Convenience function to create aPFBuilderwith the first case statement added.static <F,T> PFBuilder<F, T> matchUnchecked(Class<?> type, Function<?, T> apply) Convenience function to create aPFBuilderwith the first case statement added without compile time type check of the parameters.static <F,T> PFBuilder<F, T> matchUnchecked(Class<?> type, Predicate<?> predicate, Function<?, T> apply) Convenience function to create aPFBuilderwith the first case statement added without compile time type check of the parameters.
-
Field Details
-
statements
-
-
Method Details
-
match
Convenience function to create aPFBuilderwith the first 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
- See Also:
-
matchUnchecked
Convenience function to create aPFBuilderwith the first case statement added 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.classand(List<String> list) -> {}. -
match
public static <F,T, PFBuilder<F,P> T> match(Class<P> type, Predicate<P> predicate, Function<P, T> apply) Convenience function to create aPFBuilderwith the first 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- Returns:
- a builder with the case statement added
- See Also:
-
matchUnchecked
public static <F,T> PFBuilder<F,T> matchUnchecked(Class<?> type, Predicate<?> predicate, Function<?, T> apply) Convenience function to create aPFBuilderwith the first case statement added 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.classand(List<String> list) -> {}. -
matchEquals
Convenience function to create aPFBuilderwith the first case statement added.- 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
- See Also:
-
matchAny
Convenience function to create aPFBuilderwith the first case statement added.- Parameters:
apply- an action to apply to the argument- Returns:
- a builder with the case statement added
- See Also:
-
create
Create aMatchfrom the builder.- Parameters:
builder- a builder representing the partial function- Returns:
- a
Matchthat can be reused
-
match
Convenience function to make the Java code more readable.Match<X, Y> matcher = Match.create(...); Y someY = matcher.match(obj);- Parameters:
i- the argument to apply the match to- Returns:
- the result of the application
- Throws:
scala.MatchError- if there is no match
-
asPF
Turn thisMatchinto aPartialFunction.- Returns:
- a partial function representation ot his
Match
-