Package io.vavr
Class API.Match<T>
java.lang.Object
io.vavr.API.Match<T>
- Type Parameters:
T- type of the object that is matched
- Enclosing class:
API
Scala-like structural pattern matching for Java. Instances are obtained via
API.Match(Object).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBase interface for all the Casesstatic final classAPI.Match.Caseimplementation for simplest casestatic final classAPI.Match.Caseimplementation for a case with 1 intermediate typestatic final classAPI.Match.Caseimplementation for a case with 2 intermediate typesstatic final classAPI.Match.Caseimplementation for a case with 3 intermediate typesstatic final classAPI.Match.Caseimplementation for a case with 4 intermediate typesstatic final classAPI.Match.Caseimplementation for a case with 5 intermediate typesstatic final classAPI.Match.Caseimplementation for a case with 6 intermediate typesstatic final classAPI.Match.Caseimplementation for a case with 7 intermediate typesstatic final classAPI.Match.Caseimplementation for a case with 8 intermediate typesstatic interfaceA Pattern is a partialFunctionin the sense that a function applications returns an optional result of typeOption<R>.static classAAPI.Match.Patternimplementation for the simplest patternstatic classAAPI.Match.Patternimplementation for the pattern with 1 intermediate typestatic classAAPI.Match.Patternimplementation for the pattern with 2 intermediate typesstatic classAAPI.Match.Patternimplementation for the pattern with 3 intermediate typesstatic classAAPI.Match.Patternimplementation for the pattern with 4 intermediate typesstatic classAAPI.Match.Patternimplementation for the pattern with 5 intermediate typesstatic classAAPI.Match.Patternimplementation for the pattern with 6 intermediate typesstatic classAAPI.Match.Patternimplementation for the pattern with 7 intermediate typesstatic classAAPI.Match.Patternimplementation for the pattern with 8 intermediate types -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <R> Rof(@NonNull API.Match.Case<? extends T, ? extends R> @NonNull ... cases) Executes the match, created by the factory functionAPI.Match(Object).final <R> Option<R> option(@NonNull API.Match.Case<? extends T, ? extends R> @NonNull ... cases) Executes the match, created by the factory functionAPI.Match(Object).
-
Field Details
-
value
-
-
Constructor Details
-
Match
-
-
Method Details
-
of
@SafeVarargs public final <R> R of(@NonNull API.Match.Case<? extends T, ? extends R> @NonNull ... cases) Executes the match, created by the factory functionAPI.Match(Object). Throws exceptions when the list ofAPI.Match.Cases is incomplete.- Type Parameters:
R- return value type- Parameters:
cases- list of cases we execute the match against- Returns:
- The matched value
- Throws:
MatchError- if the list of cases was not defined for all possible values of T
-
option
@SafeVarargs public final <R> Option<R> option(@NonNull API.Match.Case<? extends T, ? extends R> @NonNull ... cases) Executes the match, created by the factory functionAPI.Match(Object). Returns Option.some(...) if the value was matched and Option.none() otherwise.- Type Parameters:
R- return value type- Parameters:
cases- list of cases we execute the match against- Returns:
- Option containing the matched value, or none
-