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
@GwtIncompatible public static final class API.Match<T> extends java.lang.Object
Scala-like structural pattern matching for Java. Instances are obtained viaAPI.Match(Object).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAPI.Match.Case<T,R>Base interface for all the Casesstatic classAPI.Match.Case0<T,R>API.Match.Caseimplementation for simplest casestatic classAPI.Match.Case1<T,T1,R>API.Match.Caseimplementation for a case with 1 intermediate typestatic classAPI.Match.Case2<T,T1,T2,R>API.Match.Caseimplementation for a case with 2 intermediate typesstatic classAPI.Match.Case3<T,T1,T2,T3,R>API.Match.Caseimplementation for a case with 3 intermediate typesstatic classAPI.Match.Case4<T,T1,T2,T3,T4,R>API.Match.Caseimplementation for a case with 4 intermediate typesstatic classAPI.Match.Case5<T,T1,T2,T3,T4,T5,R>API.Match.Caseimplementation for a case with 5 intermediate typesstatic classAPI.Match.Case6<T,T1,T2,T3,T4,T5,T6,R>API.Match.Caseimplementation for a case with 6 intermediate typesstatic classAPI.Match.Case7<T,T1,T2,T3,T4,T5,T6,T7,R>API.Match.Caseimplementation for a case with 7 intermediate typesstatic classAPI.Match.Case8<T,T1,T2,T3,T4,T5,T6,T7,T8,R>API.Match.Caseimplementation for a case with 8 intermediate typesstatic interfaceAPI.Match.Pattern<T,R>A Pattern is a partialFunctionin the sense that a function applications returns an optional result of typeOption<R>.static classAPI.Match.Pattern0<T>AAPI.Match.Patternimplementation for the simplest patternstatic classAPI.Match.Pattern1<T,T1>AAPI.Match.Patternimplementation for the pattern with 1 intermediate typestatic classAPI.Match.Pattern2<T,T1,T2>AAPI.Match.Patternimplementation for the pattern with 2 intermediate typesstatic classAPI.Match.Pattern3<T,T1,T2,T3>AAPI.Match.Patternimplementation for the pattern with 3 intermediate typesstatic classAPI.Match.Pattern4<T,T1,T2,T3,T4>AAPI.Match.Patternimplementation for the pattern with 4 intermediate typesstatic classAPI.Match.Pattern5<T,T1,T2,T3,T4,T5>AAPI.Match.Patternimplementation for the pattern with 5 intermediate typesstatic classAPI.Match.Pattern6<T,T1,T2,T3,T4,T5,T6>AAPI.Match.Patternimplementation for the pattern with 6 intermediate typesstatic classAPI.Match.Pattern7<T,T1,T2,T3,T4,T5,T6,T7>AAPI.Match.Patternimplementation for the pattern with 7 intermediate typesstatic classAPI.Match.Pattern8<T,T1,T2,T3,T4,T5,T6,T7,T8>AAPI.Match.Patternimplementation for the pattern with 8 intermediate types
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> Rof(@NonNull API.Match.Case<? extends T,? extends R> @NonNull ... cases)Executes the match, created by the factory functionAPI.Match(Object).<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 Detail
-
value
private final T value
-
-
Constructor Detail
-
Match
private Match(T value)
-
-
Method Detail
-
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
-
-