@Test public void testIfThen() { assertEquals(some("hallo"), some("hello").map(ifThen("hello", "hallo"))); assertEquals(some(-1), some("none").map(ifThen("none", "-1")).bind(Strings.toInt).orError(new RuntimeException())); assertEquals(some(300), some("300").map(ifThen("none", "-1")).bind(Strings.toInt).orError(new RuntimeException())); }
public static <A> Function<A, A> ifThen(final A predicate, final A b) { return new Function<A, A>() { @Override public A apply(A a) { return predicate.equals(a) ? b : a; } }; }
Misc { public static <A> Function<A, A> ifThen(final A predicate, final A b) { return new Function<A, A>() { @Override public A apply(A a) { return predicate.equals(a) ? b : a; } }; } }
Misc { public static <A> Function<A, A> ifThen(final A predicate, final A b) { return new Function<A, A>() { @Override public A apply(A a) { return predicate.equals(a) ? b : a; } }; } private  Misc(); }
Misc { public static <A> Function<A, A> ifThen(final A predicate, final A b) { return new Function<A, A>() { @Override public A apply(A a) { return predicate.equals(a) ? b : a; } }; } private  Misc(); static A chuck(Throwable t); static Function<A, B> chuck(); static B cast(A v, Class<B> to); static Function<A, B> cast(); static List<A> widen(List<? extends A> xs); static Option<A> widen(Option<? extends A> xs); static Function<A, A> ifThen(final A predicate, final A b); }
Misc { public static <A> Function<A, A> ifThen(final A predicate, final A b) { return new Function<A, A>() { @Override public A apply(A a) { return predicate.equals(a) ? b : a; } }; } private  Misc(); static A chuck(Throwable t); static Function<A, B> chuck(); static B cast(A v, Class<B> to); static Function<A, B> cast(); static List<A> widen(List<? extends A> xs); static Option<A> widen(Option<? extends A> xs); static Function<A, A> ifThen(final A predicate, final A b);  }