/** * Sets a {@link Function2} to execute if this matches. */ public <R> FluentMatchingR<T, R> get(Function2<A, B, R> function) { return get(new FluentMatchingR<>(value), function); }
/** * Specifies an match on a decomposing matcher with 2 extracted fields and then returns a fluent * interface for specifying the action to take if the value matches this case. */ public <U extends T, A, B> InitialMatching2<T, U, A, B> when( DecomposableMatchBuilder2<U, A, B> decomposableMatchBuilder) { return new InitialMatching2<>(decomposableMatchBuilder.build(), value); }
/** * Sets a {@link Consumer2} to execute if this matches. */ public FluentMatchingC<T> then(Consumer2<A, B> consumer) { return then(new FluentMatchingC<>(value), consumer); } }
private Optional<List<String>> getPowersForAlterEgo( Character character, Civilian alterEgo) { return match(character) .when(case2(Civilian.class, any(), any())) .get((n, w) -> Optional.<List<String>>empty()) .when(case3(SuperHero.class, eq(""), any(), eq(Optional.of(alterEgo)))).get( p -> Optional.of(p)) .orElse(Optional.empty()) .getMatch(); } }