T - X - public class MatchingInstance<T,X>
extends java.lang.Object
implements java.util.function.Function<T,java.util.Optional<X>>
| Constructor and Description |
|---|
MatchingInstance() |
| Modifier and Type | Method and Description |
|---|---|
java.util.Optional<X> |
apply(java.lang.Object t) |
java.util.function.Function<T,java.util.stream.Stream<X>> |
asStreamFunction() |
java.util.function.Function<T,X> |
asUnwrappedFunction() |
Cases<T,X,ActionWithReturn<T,X>> |
cases() |
java.util.Optional<X> |
match(java.lang.Object... t)
Aggregates supplied objects into a List for matching against
|
java.util.Optional<X> |
match(java.lang.Object t) |
<R> java.util.stream.Stream<R> |
matchFromStream(java.util.stream.Stream s)
Each input element can generated a single matched value
|
<R> java.util.stream.Stream<R> |
matchMany(java.lang.Object t) |
<R> java.util.stream.Stream<R> |
matchManyFromStream(java.util.stream.Stream s)
Each input element can generated multiple matched values
|
java.util.Optional<X> |
unapply(com.aol.cyclops.lambda.api.Decomposable decomposableObject)
Immediately decompose the supplied parameter and pass it to the PatternMatcher for matching
|
ElementCase<X> |
when()
Create a builder for Matching against a provided Object as is (i.e.
|
MatchingInstance<? extends java.lang.Object,X> |
when(java.util.function.Function<ElementCase<X>,MatchingInstance<? extends java.lang.Object,X>> fn)
Deprecated.
|
StreamCase |
whenFromStream()
Create a builder that builds Pattern Matching Cases from Streams of data.
|
IterableCase<X> |
whenIterable()
Create a builder for matching on the disaggregated elements of a collection.
|
MatchingInstance<? extends java.lang.Object,X> |
whenIterable(java.util.function.Function<IterableCase<? extends java.lang.Object>,MatchingInstance<? extends java.lang.Object,X>> fn)
Create a builder for matching on the disaggregated elements of a collection.
|
MatchingInstance<T,X> |
whenStream(java.util.function.Function<CaseBeingBuilt,MatchingInstance<T,X>> fn)
Deprecated.
|
CheckTypeAndValues<X> |
whenValues()
Create a builder for Matching on Case classes.
|
MatchingInstance<? extends java.lang.Object,X> |
whenValues(java.util.function.Function<CheckTypeAndValues<? extends java.lang.Object>,MatchingInstance<? extends java.lang.Object,X>> fn)
Deprecated.
|
public final CheckTypeAndValues<X> whenValues()
\@Value final class CaseClass implements Decomposable { int field1; String field2;}
Use with static imports from the Predicates class to get wildcards via '__' or ANY()
And to apply nested / recursive matching via Predicates.type( ).with ( )
Match disaggregated elements by type, value, JDK 8 Predicate or Hamcrest Matcherpublic final ElementCase<X> when()
public final IterableCase<X> whenIterable()
public final StreamCase whenFromStream()
@Deprecated public final MatchingInstance<? extends java.lang.Object,X> whenValues(java.util.function.Function<CheckTypeAndValues<? extends java.lang.Object>,MatchingInstance<? extends java.lang.Object,X>> fn)
\@Value final class CaseClass implements Decomposable { int field1; String field2;}
Use with static imports from the Predicates class to get wildcards via '__' or ANY()
And to apply nested / recursive matching via Predicates.type( ).with ( )
Match disaggregated elements by type, value, JDK 8 Predicate or Hamcrest Matcherfn - Function that accepts the Case for Case classes and returns the output of that builder@Deprecated public final MatchingInstance<? extends java.lang.Object,X> when(java.util.function.Function<ElementCase<X>,MatchingInstance<? extends java.lang.Object,X>> fn)
fn - Function that accepts a Simplex Element based Pattern Matching Builder and returns it's outputpublic final MatchingInstance<? extends java.lang.Object,X> whenIterable(java.util.function.Function<IterableCase<? extends java.lang.Object>,MatchingInstance<? extends java.lang.Object,X>> fn)
fn - a Function that accepts a Iterable / Collection based Pattern Matching Builder and returns it's output@Deprecated public final MatchingInstance<T,X> whenStream(java.util.function.Function<CaseBeingBuilt,MatchingInstance<T,X>> fn)
fn - a function that accepts a Stream based pattern matching builderpublic java.util.function.Function<T,X> asUnwrappedFunction()
public java.util.function.Function<T,java.util.stream.Stream<X>> asStreamFunction()
public java.util.Optional<X> apply(java.lang.Object t)
public <R> java.util.stream.Stream<R> matchManyFromStream(java.util.stream.Stream s)
s - Stream of data to match against (input to matcher)public <R> java.util.stream.Stream<R> matchMany(java.lang.Object t)
t - input to match against - can generate multiple valuespublic <R> java.util.stream.Stream<R> matchFromStream(java.util.stream.Stream s)
s - Stream of data to match against (input to matcher)public java.util.Optional<X> match(java.lang.Object... t)
assertThat(Cases.of(Case.of((List<Integer> input) -> input.size()==3, input -> "hello"),
Case.of((List<Integer> input) -> input.size()==2, input -> "ignored"),
Case.of((List<Integer> input) -> input.size()==1, input -> "world")).match(1,2,3).get(),is("hello"));
t - Array to match onpublic java.util.Optional<X> match(java.lang.Object t)
t - Object to match against supplied casespublic java.util.Optional<X> unapply(com.aol.cyclops.lambda.api.Decomposable decomposableObject)
decomposableObject - Object to match on after decomposed via unapply method