public interface Matchable
| Modifier and Type | Method and Description |
|---|---|
default java.lang.Object |
getMatchable() |
static Matchable |
listOfValues(java.lang.Object... o)
Create a matchable that matches on the provided Objects
|
default <T,R> R |
matches(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1)
Match against the values inside the matchable with a single case
|
default <T,R> R |
matches(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2)
Match against the values inside the matchable with two cases
|
default <T,R> R |
matches(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3) |
default <T,R> R |
matches(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn4) |
default <T,R> R |
matches(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn4,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn5) |
default <T,R> java.util.Optional<R> |
mayMatch(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1) |
default <T,R> java.util.Optional<R> |
mayMatch(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2) |
default <T,R> java.util.Optional<R> |
mayMatch(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3) |
default <T,R> java.util.Optional<R> |
mayMatch(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn4) |
default <T,R> java.util.Optional<R> |
mayMatch(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn4,
java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn5) |
static Matchable |
of(java.lang.Object o)
Create a new matchable that will match on the fields of the provided Object
|
static Matchable |
ofDecomposable(com.aol.cyclops.objects.Decomposable o)
Create a new matchable that will match on the fields of the provided Decomposable
|
static <T> Matchable |
ofStream(java.util.stream.Stream<T> o)
Create a new matchable that will match on the fields of the provided Stream
|
default java.lang.Object getMatchable()
default <T,R> R matches(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1)
int result = Matchable.of(Optional.of(1))
.matches(c->c.hasValues(1).then(i->2));
//2
Note, it is possible to continue to chain cases within a single case, but cleaner
to use the appropriate overloaded matches method that accepts two (or more) cases.fn1 - Describes the matching casedefault <T,R> R matches(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2)
int result = Matchable.listOfValues(1,2)
.matches(c->c.hasValues(1,3).then(i->2),
c->c.hasValues(1,2).then(i->3));
//3
Note, it is possible to continue to chain cases within a single case, but cleaner
to use the appropriate overloaded matches method that accepts three (or more) cases.fn1 - Describes a casefn2 - Describes a casedefault <T,R> R matches(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3)
default <T,R> R matches(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn4)
default <T,R> R matches(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn4, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn5)
default <T,R> java.util.Optional<R> mayMatch(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1)
default <T,R> java.util.Optional<R> mayMatch(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2)
default <T,R> java.util.Optional<R> mayMatch(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3)
default <T,R> java.util.Optional<R> mayMatch(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn4)
default <T,R> java.util.Optional<R> mayMatch(java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn1, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn2, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn3, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn4, java.util.function.Function<CheckValues<? super T,R>,CheckValues<? super T,R>> fn5)
static Matchable of(java.lang.Object o)
o - Object to match on it's fieldsstatic <T> Matchable ofStream(java.util.stream.Stream<T> o)
o - Object to match on it's fieldsstatic Matchable ofDecomposable(com.aol.cyclops.objects.Decomposable o)
o - Decomposable to match on it's fieldsstatic Matchable listOfValues(java.lang.Object... o)
o - Objects to match on