示例#1
0
 public <U1, U2, U3, U4> Tuple4<U1, U2, U3, U4> map(
     Function1<? super T1, ? extends U1> f1,
     Function1<? super T2, ? extends U2> f2,
     Function1<? super T3, ? extends U3> f3,
     Function1<? super T4, ? extends U4> f4) {
   return map(
       (t1, t2, t3, t4) -> Tuple.of(f1.apply(t1), f2.apply(t2), f3.apply(t3), f4.apply(t4)));
 }
示例#2
0
 /**
  * Lifts the given {@code partialFunction} into a total function that returns an {@code Option}
  * result.
  *
  * @param partialFunction a function that is not defined for all values of the domain (e.g. by
  *     throwing)
  * @param <R> return type
  * @param <T1> 1st argument
  * @return a function that applies arguments to the given {@code partialFunction} and returns
  *     {@code Some(result)} if the function is defined for the given arguments, and {@code None}
  *     otherwise.
  */
 static <T1, R> Function1<T1, Option<R>> lift(Function1<T1, R> partialFunction) {
   return (t1) -> Try.of(() -> partialFunction.apply(t1)).getOption();
 }
示例#3
0
 /**
  * Returns a composed function that first applies this Function2 to the given argument and then
  * applies {@linkplain Function1} {@code after} to the result.
  *
  * @param <V> return type of after
  * @param after the function applied after this
  * @return a function composed of this and after
  * @throws NullPointerException if after is null
  */
 default <V> Function2<T1, T2, V> andThen(Function1<? super R, ? extends V> after) {
   Objects.requireNonNull(after, "after is null");
   return (t1, t2) -> after.apply(apply(t1, t2));
 }
示例#4
0
 /**
  * Returns a composed function that first applies the {@linkplain Function1} {@code before} the
  * given argument and then applies this Function1 to the result.
  *
  * @param <V> argument type of before
  * @param before the function applied before this
  * @return a function composed of before and this
  * @throws NullPointerException if before is null
  */
 default <V> Function1<V, R> compose(Function1<? super V, ? extends T1> before) {
   Objects.requireNonNull(before, "before is null");
   return v -> apply(before.apply(v));
 }
示例#5
0
 public <U1> Tuple1<U1> map(Function1<? super T1, ? extends U1> f) {
   return new Tuple1<>(f.apply(_1));
 }