http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function14.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function14.java b/src/main/groovy/groovy/util/function/Function14.java new file mode 100644 index 0000000..72c7d77 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function14.java @@ -0,0 +1,255 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple10; +import groovy.lang.Tuple11; +import groovy.lang.Tuple12; +import groovy.lang.Tuple13; +import groovy.lang.Tuple14; +import groovy.lang.Tuple2; +import groovy.lang.Tuple3; +import groovy.lang.Tuple4; +import groovy.lang.Tuple5; +import groovy.lang.Tuple6; +import groovy.lang.Tuple7; +import groovy.lang.Tuple8; +import groovy.lang.Tuple9; + + +/** + * A function with 14 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple14<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13, ? extends T14> args) { + return apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), args.v14()); + } + + /** + * Apply this function to the arguments. + */ + R apply(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14); + + /** + * Partially apply this function to the arguments. + */ + default Function13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function12<T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function11<T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8, v9, v10, v11, v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T8, T9, T10, T11, T12, T13, T14, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8, v9, v10, v11, v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T9, T10, T11, T12, T13, T14, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return (v9, v10, v11, v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T10, T11, T12, T13, T14, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) { + return (v10, v11, v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T11, T12, T13, T14, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) { + return (v11, v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T12, T13, T14, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11) { + return (v12, v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T13, T14, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12) { + return (v13, v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T14, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13) { + return (v14) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) { + return () -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(args.v1(), v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function12<T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function11<T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T6, T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8, v9, v10, v11, v12, v13, v14) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T7, T8, T9, T10, T11, T12, T13, T14, R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8, v9, v10, v11, v12, v13, v14) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T8, T9, T10, T11, T12, T13, T14, R> applyPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return (v8, v9, v10, v11, v12, v13, v14) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8, v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T9, T10, T11, T12, T13, T14, R> applyPartially(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + return (v9, v10, v11, v12, v13, v14) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), v9, v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T10, T11, T12, T13, T14, R> applyPartially(Tuple9<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9> args) { + return (v10, v11, v12, v13, v14) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), v10, v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T11, T12, T13, T14, R> applyPartially(Tuple10<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10> args) { + return (v11, v12, v13, v14) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), v11, v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T12, T13, T14, R> applyPartially(Tuple11<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11> args) { + return (v12, v13, v14) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), v12, v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T13, T14, R> applyPartially(Tuple12<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12> args) { + return (v13, v14) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), v13, v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T14, R> applyPartially(Tuple13<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13> args) { + return (v14) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), v14); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple14<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13, ? extends T14> args) { + return () -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), args.v14()); + } + +}
http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function15.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function15.java b/src/main/groovy/groovy/util/function/Function15.java new file mode 100644 index 0000000..1265ff3 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function15.java @@ -0,0 +1,270 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple10; +import groovy.lang.Tuple11; +import groovy.lang.Tuple12; +import groovy.lang.Tuple13; +import groovy.lang.Tuple14; +import groovy.lang.Tuple15; +import groovy.lang.Tuple2; +import groovy.lang.Tuple3; +import groovy.lang.Tuple4; +import groovy.lang.Tuple5; +import groovy.lang.Tuple6; +import groovy.lang.Tuple7; +import groovy.lang.Tuple8; +import groovy.lang.Tuple9; + + +/** + * A function with 15 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple15<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13, ? extends T14, ? extends T15> args) { + return apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), args.v14(), args.v15()); + } + + /** + * Apply this function to the arguments. + */ + R apply(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15); + + /** + * Partially apply this function to the arguments. + */ + default Function14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function13<T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function12<T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function11<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8, v9, v10, v11, v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T9, T10, T11, T12, T13, T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return (v9, v10, v11, v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T10, T11, T12, T13, T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) { + return (v10, v11, v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T11, T12, T13, T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) { + return (v11, v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T12, T13, T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11) { + return (v12, v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T13, T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12) { + return (v13, v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T14, T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13) { + return (v14, v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T15, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) { + return (v15) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) { + return () -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(args.v1(), v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function13<T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function12<T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function11<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T7, T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8, v9, v10, v11, v12, v13, v14, v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T8, T9, T10, T11, T12, T13, T14, T15, R> applyPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return (v8, v9, v10, v11, v12, v13, v14, v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8, v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T9, T10, T11, T12, T13, T14, T15, R> applyPartially(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + return (v9, v10, v11, v12, v13, v14, v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), v9, v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T10, T11, T12, T13, T14, T15, R> applyPartially(Tuple9<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9> args) { + return (v10, v11, v12, v13, v14, v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), v10, v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T11, T12, T13, T14, T15, R> applyPartially(Tuple10<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10> args) { + return (v11, v12, v13, v14, v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), v11, v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T12, T13, T14, T15, R> applyPartially(Tuple11<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11> args) { + return (v12, v13, v14, v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), v12, v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T13, T14, T15, R> applyPartially(Tuple12<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12> args) { + return (v13, v14, v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), v13, v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T14, T15, R> applyPartially(Tuple13<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13> args) { + return (v14, v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), v14, v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T15, R> applyPartially(Tuple14<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13, ? extends T14> args) { + return (v15) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), args.v14(), v15); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple15<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13, ? extends T14, ? extends T15> args) { + return () -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), args.v14(), args.v15()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function16.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function16.java b/src/main/groovy/groovy/util/function/Function16.java new file mode 100644 index 0000000..27e6f31 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function16.java @@ -0,0 +1,285 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple10; +import groovy.lang.Tuple11; +import groovy.lang.Tuple12; +import groovy.lang.Tuple13; +import groovy.lang.Tuple14; +import groovy.lang.Tuple15; +import groovy.lang.Tuple16; +import groovy.lang.Tuple2; +import groovy.lang.Tuple3; +import groovy.lang.Tuple4; +import groovy.lang.Tuple5; +import groovy.lang.Tuple6; +import groovy.lang.Tuple7; +import groovy.lang.Tuple8; +import groovy.lang.Tuple9; + + +/** + * A function with 16 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple16<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13, ? extends T14, ? extends T15, ? extends T16> args) { + return apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), args.v14(), args.v15(), args.v16()); + } + + /** + * Apply this function to the arguments. + */ + R apply(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16); + + /** + * Partially apply this function to the arguments. + */ + default Function15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function14<T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function13<T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function12<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function11<T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return (v9, v10, v11, v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T10, T11, T12, T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) { + return (v10, v11, v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T11, T12, T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) { + return (v11, v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T12, T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11) { + return (v12, v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T13, T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12) { + return (v13, v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T14, T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13) { + return (v14, v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T15, T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) { + return (v15, v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T16, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) { + return (v16) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16) { + return () -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(args.v1(), v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function14<T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function13<T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function12<T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function11<T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T8, T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return (v8, v9, v10, v11, v12, v13, v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8, v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T9, T10, T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + return (v9, v10, v11, v12, v13, v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), v9, v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T10, T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple9<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9> args) { + return (v10, v11, v12, v13, v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), v10, v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T11, T12, T13, T14, T15, T16, R> applyPartially(Tuple10<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10> args) { + return (v11, v12, v13, v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), v11, v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T12, T13, T14, T15, T16, R> applyPartially(Tuple11<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11> args) { + return (v12, v13, v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), v12, v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T13, T14, T15, T16, R> applyPartially(Tuple12<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12> args) { + return (v13, v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), v13, v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T14, T15, T16, R> applyPartially(Tuple13<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13> args) { + return (v14, v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), v14, v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T15, T16, R> applyPartially(Tuple14<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13, ? extends T14> args) { + return (v15, v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), args.v14(), v15, v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T16, R> applyPartially(Tuple15<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13, ? extends T14, ? extends T15> args) { + return (v16) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), args.v14(), args.v15(), v16); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple16<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10, ? extends T11, ? extends T12, ? extends T13, ? extends T14, ? extends T15, ? extends T16> args) { + return () -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), args.v12(), args.v13(), args.v14(), args.v15(), args.v16()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function2.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function2.java b/src/main/groovy/groovy/util/function/Function2.java new file mode 100644 index 0000000..20216c8 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function2.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple2; + +import java.util.function.BiFunction; + +/** + * A function with 2 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function2<T1, T2, R> extends BiFunction<T1, T2, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple2<? extends T1, ? extends T2> args) { + return apply(args.v1(), args.v2()); + } + + /** + * Apply this function to the arguments. + */ + @Override + R apply(T1 v1, T2 v2); + + /** + * Convert this function to a {@link BiFunction}. + */ + default BiFunction<T1, T2, R> toBiFunction() { + return this::apply; + } + + /** + * Convert to this function from a {@link BiFunction}. + */ + static <T1, T2, R> Function2<T1, T2, R> from(BiFunction<? super T1, ? super T2, ? extends R> function) { + return function::apply; + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T2, R> applyPartially(T1 v1) { + return (v2) -> apply(v1, v2); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2) { + return () -> apply(v1, v2); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T2, R> applyPartially(Tuple1<? extends T1> args) { + return (v2) -> apply(args.v1(), v2); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return () -> apply(args.v1(), args.v2()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function3.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function3.java b/src/main/groovy/groovy/util/function/Function3.java new file mode 100644 index 0000000..eed1a3e --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function3.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple2; +import groovy.lang.Tuple3; + + +/** + * A function with 3 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function3<T1, T2, T3, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return apply(args.v1(), args.v2(), args.v3()); + } + + /** + * Apply this function to the arguments. + */ + R apply(T1 v1, T2 v2, T3 v3); + + /** + * Partially apply this function to the arguments. + */ + default Function2<T2, T3, R> applyPartially(T1 v1) { + return (v2, v3) -> apply(v1, v2, v3); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T3, R> applyPartially(T1 v1, T2 v2) { + return (v3) -> apply(v1, v2, v3); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2, T3 v3) { + return () -> apply(v1, v2, v3); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T2, T3, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3) -> apply(args.v1(), v2, v3); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T3, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3) -> apply(args.v1(), args.v2(), v3); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return () -> apply(args.v1(), args.v2(), args.v3()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function4.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function4.java b/src/main/groovy/groovy/util/function/Function4.java new file mode 100644 index 0000000..f496a82 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function4.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple2; +import groovy.lang.Tuple3; +import groovy.lang.Tuple4; + + +/** + * A function with 4 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function4<T1, T2, T3, T4, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return apply(args.v1(), args.v2(), args.v3(), args.v4()); + } + + /** + * Apply this function to the arguments. + */ + R apply(T1 v1, T2 v2, T3 v3, T4 v4); + + /** + * Partially apply this function to the arguments. + */ + default Function3<T2, T3, T4, R> applyPartially(T1 v1) { + return (v2, v3, v4) -> apply(v1, v2, v3, v4); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T3, T4, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4) -> apply(v1, v2, v3, v4); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T4, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4) -> apply(v1, v2, v3, v4); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return () -> apply(v1, v2, v3, v4); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T2, T3, T4, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4) -> apply(args.v1(), v2, v3, v4); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T3, T4, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4) -> apply(args.v1(), args.v2(), v3, v4); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T4, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4) -> apply(args.v1(), args.v2(), args.v3(), v4); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return () -> apply(args.v1(), args.v2(), args.v3(), args.v4()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function5.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function5.java b/src/main/groovy/groovy/util/function/Function5.java new file mode 100644 index 0000000..d2d545e --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function5.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple2; +import groovy.lang.Tuple3; +import groovy.lang.Tuple4; +import groovy.lang.Tuple5; + + +/** + * A function with 5 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function5<T1, T2, T3, T4, T5, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5()); + } + + /** + * Apply this function to the arguments. + */ + R apply(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5); + + /** + * Partially apply this function to the arguments. + */ + default Function4<T2, T3, T4, T5, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5) -> apply(v1, v2, v3, v4, v5); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T3, T4, T5, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5) -> apply(v1, v2, v3, v4, v5); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T4, T5, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5) -> apply(v1, v2, v3, v4, v5); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T5, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5) -> apply(v1, v2, v3, v4, v5); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return () -> apply(v1, v2, v3, v4, v5); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T2, T3, T4, T5, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5) -> apply(args.v1(), v2, v3, v4, v5); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T3, T4, T5, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5) -> apply(args.v1(), args.v2(), v3, v4, v5); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T4, T5, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5) -> apply(args.v1(), args.v2(), args.v3(), v4, v5); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T5, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return () -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function6.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function6.java b/src/main/groovy/groovy/util/function/Function6.java new file mode 100644 index 0000000..21bb27c --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function6.java @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple2; +import groovy.lang.Tuple3; +import groovy.lang.Tuple4; +import groovy.lang.Tuple5; +import groovy.lang.Tuple6; + + +/** + * A function with 6 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function6<T1, T2, T3, T4, T5, T6, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6()); + } + + /** + * Apply this function to the arguments. + */ + R apply(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6); + + /** + * Partially apply this function to the arguments. + */ + default Function5<T2, T3, T4, T5, T6, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6) -> apply(v1, v2, v3, v4, v5, v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T3, T4, T5, T6, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6) -> apply(v1, v2, v3, v4, v5, v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T4, T5, T6, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6) -> apply(v1, v2, v3, v4, v5, v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T5, T6, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6) -> apply(v1, v2, v3, v4, v5, v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T6, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6) -> apply(v1, v2, v3, v4, v5, v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return () -> apply(v1, v2, v3, v4, v5, v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T2, T3, T4, T5, T6, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6) -> apply(args.v1(), v2, v3, v4, v5, v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T3, T4, T5, T6, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6) -> apply(args.v1(), args.v2(), v3, v4, v5, v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T4, T5, T6, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T5, T6, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T6, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return () -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function7.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function7.java b/src/main/groovy/groovy/util/function/Function7.java new file mode 100644 index 0000000..f1e4917 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function7.java @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple2; +import groovy.lang.Tuple3; +import groovy.lang.Tuple4; +import groovy.lang.Tuple5; +import groovy.lang.Tuple6; +import groovy.lang.Tuple7; + + +/** + * A function with 7 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function7<T1, T2, T3, T4, T5, T6, T7, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7()); + } + + /** + * Apply this function to the arguments. + */ + R apply(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7); + + /** + * Partially apply this function to the arguments. + */ + default Function6<T2, T3, T4, T5, T6, T7, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7) -> apply(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T3, T4, T5, T6, T7, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7) -> apply(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T4, T5, T6, T7, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7) -> apply(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T5, T6, T7, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7) -> apply(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T6, T7, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7) -> apply(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T7, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7) -> apply(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return () -> apply(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T2, T3, T4, T5, T6, T7, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7) -> apply(args.v1(), v2, v3, v4, v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T3, T4, T5, T6, T7, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7) -> apply(args.v1(), args.v2(), v3, v4, v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T4, T5, T6, T7, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T5, T6, T7, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T6, T7, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T7, R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return () -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function8.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function8.java b/src/main/groovy/groovy/util/function/Function8.java new file mode 100644 index 0000000..5729d84 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function8.java @@ -0,0 +1,165 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple2; +import groovy.lang.Tuple3; +import groovy.lang.Tuple4; +import groovy.lang.Tuple5; +import groovy.lang.Tuple6; +import groovy.lang.Tuple7; +import groovy.lang.Tuple8; + + +/** + * A function with 8 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function8<T1, T2, T3, T4, T5, T6, T7, T8, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + return apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8()); + } + + /** + * Apply this function to the arguments. + */ + R apply(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8); + + /** + * Partially apply this function to the arguments. + */ + default Function7<T2, T3, T4, T5, T6, T7, T8, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8) -> apply(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T3, T4, T5, T6, T7, T8, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8) -> apply(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T4, T5, T6, T7, T8, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8) -> apply(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T5, T6, T7, T8, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8) -> apply(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T6, T7, T8, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8) -> apply(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T7, T8, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8) -> apply(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T8, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8) -> apply(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return () -> apply(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T2, T3, T4, T5, T6, T7, T8, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8) -> apply(args.v1(), v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T3, T4, T5, T6, T7, T8, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8) -> apply(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T4, T5, T6, T7, T8, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T5, T6, T7, T8, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T6, T7, T8, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T7, T8, R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T8, R> applyPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return (v8) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + return () -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function9.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function9.java b/src/main/groovy/groovy/util/function/Function9.java new file mode 100644 index 0000000..a82be5e --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function9.java @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.util.function; + +import groovy.lang.Tuple1; +import groovy.lang.Tuple2; +import groovy.lang.Tuple3; +import groovy.lang.Tuple4; +import groovy.lang.Tuple5; +import groovy.lang.Tuple6; +import groovy.lang.Tuple7; +import groovy.lang.Tuple8; +import groovy.lang.Tuple9; + + +/** + * A function with 9 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function9<T1, T2, T3, T4, T5, T6, T7, T8, T9, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple9<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9> args) { + return apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9()); + } + + /** + * Apply this function to the arguments. + */ + R apply(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9); + + /** + * Partially apply this function to the arguments. + */ + default Function8<T2, T3, T4, T5, T6, T7, T8, T9, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8, v9) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T3, T4, T5, T6, T7, T8, T9, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8, v9) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T4, T5, T6, T7, T8, T9, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8, v9) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T5, T6, T7, T8, T9, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8, v9) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T6, T7, T8, T9, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8, v9) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T7, T8, T9, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8, v9) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T8, T9, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8, v9) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T9, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return (v9) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) { + return () -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T2, T3, T4, T5, T6, T7, T8, T9, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8, v9) -> apply(args.v1(), v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T3, T4, T5, T6, T7, T8, T9, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8, v9) -> apply(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T4, T5, T6, T7, T8, T9, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8, v9) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T5, T6, T7, T8, T9, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8, v9) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T6, T7, T8, T9, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8, v9) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T7, T8, T9, R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8, v9) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T8, T9, R> applyPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return (v8, v9) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8, v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T9, R> applyPartially(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + return (v9) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), v9); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple9<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9> args) { + return () -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9()); + } + +}