/** * Sets a {@link Consumer0} to execute if this matches. */ public FluentMatchingC<T> then(Consumer0 consumer) { return then(new FluentMatchingC<>(value), consumer); } }
/** * Sets a no-op to be run if no match is found. * * <p>This can be used if you don't care if a match occurs and want to avoid the * {@link MatchException}. */ public FluentMatchingC<T> orElse() { patterns.add(ConsumablePattern.of(t -> true, t -> doNothing())); return this; }
FluentMatchingC<T> then(FluentMatchingC<T> fluentMatchingC, Consumer<A> consumer) { fluentMatchingC.addPattern( ConsumablePattern.of( t -> extractor.getExtractorClass().isAssignableFrom(t.getClass()) && extractor .unapply((U) t).isPresent(), t -> { A a = extractor.unapply((U) t).get(); consumer.accept(a); } ) ); return fluentMatchingC; } }
FluentMatchingC<T> then(FluentMatchingC<T> fluentMatchingC, Consumer0 consumer) { fluentMatchingC.addPattern( ConsumablePattern.of( t -> extractor.getExtractorClass().isAssignableFrom(t.getClass()) && extractor .unapply((U) t), t -> consumer.accept())); return fluentMatchingC; } }
/** * Sets a {@link Consumer2} to execute if this matches. */ public FluentMatchingC<T> then(Consumer2<A, B> consumer) { return then(new FluentMatchingC<>(value), consumer); } }
FluentMatchingC<T> then(FluentMatchingC<T> fluentMatchingC, Consumer2<A, B> consumer) { fluentMatchingC.addPattern( ConsumablePattern.of( t -> extractor.getExtractorClass().isAssignableFrom(t.getClass()) && extractor .unapply((U) t).isPresent(), t -> { Tuple2<A, B> tuple2 = extractor.unapply((U) t).get(); consumer.accept(tuple2.first(), tuple2.second()); } ) ); return fluentMatchingC; } }
/** * Sets a {@link Consumer3} to execute if this matches. */ public FluentMatchingC<T> then(Consumer3<A, B, C> consumer) { return then(new FluentMatchingC<>(value), consumer); } }
FluentMatchingC<T> then(FluentMatchingC<T> fluentMatchingC, Consumer3<A, B, C> consumer) { fluentMatchingC.addPattern( ConsumablePattern.of( t -> extractor.getExtractorClass().isAssignableFrom(t.getClass()) && extractor .unapply((U) t).isPresent(), t -> { Tuple3<A, B, C> tuple3 = extractor.unapply((U) t).get(); consumer.accept(tuple3.first(), tuple3.second(), tuple3.third()); } ) ); return fluentMatchingC; } }
/** * Sets a {@link Consumer} to execute if this matches. */ public FluentMatchingC<T> then(Consumer<A> consumer) { return then(new FluentMatchingC<>(value), consumer); } }