http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Consumer3.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Consumer3.java b/src/main/groovy/groovy/util/function/Consumer3.java new file mode 100644 index 0000000..f5ac7e2 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Consumer3.java @@ -0,0 +1,89 @@ +/* + * 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 consumer with 3 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Consumer3<T1, T2, T3> { + + /** + * Performs this operation on the given argument. + * + * @param args The arguments as a tuple. + */ + default void accept(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + accept(args.v1(), args.v2(), args.v3()); + } + + /** + * Performs this operation on the given argument. + */ + void accept(T1 v1, T2 v2, T3 v3); + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T2, T3> acceptPartially(T1 v1) { + return (v2, v3) -> accept(v1, v2, v3); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T3> acceptPartially(T1 v1, T2 v2) { + return (v3) -> accept(v1, v2, v3); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(T1 v1, T2 v2, T3 v3) { + return () -> accept(v1, v2, v3); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T2, T3> acceptPartially(Tuple1<? extends T1> args) { + return (v2, v3) -> accept(args.v1(), v2, v3); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T3> acceptPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3) -> accept(args.v1(), args.v2(), v3); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return () -> accept(args.v1(), args.v2(), args.v3()); + } +}
http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Consumer4.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Consumer4.java b/src/main/groovy/groovy/util/function/Consumer4.java new file mode 100644 index 0000000..97f7252 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Consumer4.java @@ -0,0 +1,104 @@ +/* + * 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 consumer with 4 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Consumer4<T1, T2, T3, T4> { + + /** + * Performs this operation on the given argument. + * + * @param args The arguments as a tuple. + */ + default void accept(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + accept(args.v1(), args.v2(), args.v3(), args.v4()); + } + + /** + * Performs this operation on the given argument. + */ + void accept(T1 v1, T2 v2, T3 v3, T4 v4); + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T2, T3, T4> acceptPartially(T1 v1) { + return (v2, v3, v4) -> accept(v1, v2, v3, v4); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T3, T4> acceptPartially(T1 v1, T2 v2) { + return (v3, v4) -> accept(v1, v2, v3, v4); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T4> acceptPartially(T1 v1, T2 v2, T3 v3) { + return (v4) -> accept(v1, v2, v3, v4); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return () -> accept(v1, v2, v3, v4); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T2, T3, T4> acceptPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4) -> accept(args.v1(), v2, v3, v4); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T3, T4> acceptPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4) -> accept(args.v1(), args.v2(), v3, v4); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T4> acceptPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4) -> accept(args.v1(), args.v2(), args.v3(), v4); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return () -> accept(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/Consumer5.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Consumer5.java b/src/main/groovy/groovy/util/function/Consumer5.java new file mode 100644 index 0000000..99d76a7 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Consumer5.java @@ -0,0 +1,119 @@ +/* + * 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 consumer with 5 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Consumer5<T1, T2, T3, T4, T5> { + + /** + * Performs this operation on the given argument. + * + * @param args The arguments as a tuple. + */ + default void accept(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5()); + } + + /** + * Performs this operation on the given argument. + */ + void accept(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5); + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer4<T2, T3, T4, T5> acceptPartially(T1 v1) { + return (v2, v3, v4, v5) -> accept(v1, v2, v3, v4, v5); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T3, T4, T5> acceptPartially(T1 v1, T2 v2) { + return (v3, v4, v5) -> accept(v1, v2, v3, v4, v5); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T4, T5> acceptPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5) -> accept(v1, v2, v3, v4, v5); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T5> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5) -> accept(v1, v2, v3, v4, v5); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return () -> accept(v1, v2, v3, v4, v5); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer4<T2, T3, T4, T5> acceptPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5) -> accept(args.v1(), v2, v3, v4, v5); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T3, T4, T5> acceptPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5) -> accept(args.v1(), args.v2(), v3, v4, v5); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T4, T5> acceptPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5) -> accept(args.v1(), args.v2(), args.v3(), v4, v5); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T5> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), v5); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return () -> accept(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/Consumer6.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Consumer6.java b/src/main/groovy/groovy/util/function/Consumer6.java new file mode 100644 index 0000000..6f55b57 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Consumer6.java @@ -0,0 +1,134 @@ +/* + * 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 consumer with 6 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Consumer6<T1, T2, T3, T4, T5, T6> { + + /** + * Performs this operation on the given argument. + * + * @param args The arguments as a tuple. + */ + default void accept(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6()); + } + + /** + * Performs this operation on the given argument. + */ + void accept(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6); + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer5<T2, T3, T4, T5, T6> acceptPartially(T1 v1) { + return (v2, v3, v4, v5, v6) -> accept(v1, v2, v3, v4, v5, v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer4<T3, T4, T5, T6> acceptPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6) -> accept(v1, v2, v3, v4, v5, v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T4, T5, T6> acceptPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6) -> accept(v1, v2, v3, v4, v5, v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T5, T6> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6) -> accept(v1, v2, v3, v4, v5, v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T6> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6) -> accept(v1, v2, v3, v4, v5, v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return () -> accept(v1, v2, v3, v4, v5, v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer5<T2, T3, T4, T5, T6> acceptPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6) -> accept(args.v1(), v2, v3, v4, v5, v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer4<T3, T4, T5, T6> acceptPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6) -> accept(args.v1(), args.v2(), v3, v4, v5, v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T4, T5, T6> acceptPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6) -> accept(args.v1(), args.v2(), args.v3(), v4, v5, v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T5, T6> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T6> acceptPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return () -> accept(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/Consumer7.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Consumer7.java b/src/main/groovy/groovy/util/function/Consumer7.java new file mode 100644 index 0000000..f7f022e --- /dev/null +++ b/src/main/groovy/groovy/util/function/Consumer7.java @@ -0,0 +1,149 @@ +/* + * 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 consumer with 7 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Consumer7<T1, T2, T3, T4, T5, T6, T7> { + + /** + * Performs this operation on the given argument. + * + * @param args The arguments as a tuple. + */ + default void accept(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7()); + } + + /** + * Performs this operation on the given argument. + */ + void accept(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7); + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer6<T2, T3, T4, T5, T6, T7> acceptPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7) -> accept(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer5<T3, T4, T5, T6, T7> acceptPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7) -> accept(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer4<T4, T5, T6, T7> acceptPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7) -> accept(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T5, T6, T7> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7) -> accept(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T6, T7> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7) -> accept(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T7> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7) -> accept(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return () -> accept(v1, v2, v3, v4, v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer6<T2, T3, T4, T5, T6, T7> acceptPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7) -> accept(args.v1(), v2, v3, v4, v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer5<T3, T4, T5, T6, T7> acceptPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7) -> accept(args.v1(), args.v2(), v3, v4, v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer4<T4, T5, T6, T7> acceptPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7) -> accept(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T5, T6, T7> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T6, T7> acceptPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T7> acceptPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return () -> accept(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/Consumer8.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Consumer8.java b/src/main/groovy/groovy/util/function/Consumer8.java new file mode 100644 index 0000000..e39f69c --- /dev/null +++ b/src/main/groovy/groovy/util/function/Consumer8.java @@ -0,0 +1,164 @@ +/* + * 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 consumer with 8 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Consumer8<T1, T2, T3, T4, T5, T6, T7, T8> { + + /** + * Performs this operation on the given argument. + * + * @param args The arguments as a tuple. + */ + default void accept(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8()); + } + + /** + * Performs this operation on the given argument. + */ + void accept(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8); + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer7<T2, T3, T4, T5, T6, T7, T8> acceptPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8) -> accept(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer6<T3, T4, T5, T6, T7, T8> acceptPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8) -> accept(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer5<T4, T5, T6, T7, T8> acceptPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8) -> accept(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer4<T5, T6, T7, T8> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8) -> accept(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T6, T7, T8> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8) -> accept(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T7, T8> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8) -> accept(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T8> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8) -> accept(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return () -> accept(v1, v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer7<T2, T3, T4, T5, T6, T7, T8> acceptPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8) -> accept(args.v1(), v2, v3, v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer6<T3, T4, T5, T6, T7, T8> acceptPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8) -> accept(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer5<T4, T5, T6, T7, T8> acceptPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8) -> accept(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer4<T5, T6, T7, T8> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T6, T7, T8> acceptPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T7, T8> acceptPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T8> acceptPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return (v8) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + return () -> accept(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/Consumer9.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Consumer9.java b/src/main/groovy/groovy/util/function/Consumer9.java new file mode 100644 index 0000000..ebea668 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Consumer9.java @@ -0,0 +1,179 @@ +/* + * 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 consumer with 9 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Consumer9<T1, T2, T3, T4, T5, T6, T7, T8, T9> { + + /** + * Performs this operation on the given argument. + * + * @param args The arguments as a tuple. + */ + default void accept(Tuple9<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9> args) { + accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9()); + } + + /** + * Performs this operation on the given argument. + */ + void accept(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9); + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer8<T2, T3, T4, T5, T6, T7, T8, T9> acceptPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8, v9) -> accept(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer7<T3, T4, T5, T6, T7, T8, T9> acceptPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8, v9) -> accept(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer6<T4, T5, T6, T7, T8, T9> acceptPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8, v9) -> accept(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer5<T5, T6, T7, T8, T9> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8, v9) -> accept(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer4<T6, T7, T8, T9> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8, v9) -> accept(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T7, T8, T9> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8, v9) -> accept(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T8, T9> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8, v9) -> accept(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T9> acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return (v9) -> accept(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) { + return () -> accept(v1, v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer8<T2, T3, T4, T5, T6, T7, T8, T9> acceptPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8, v9) -> accept(args.v1(), v2, v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer7<T3, T4, T5, T6, T7, T8, T9> acceptPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8, v9) -> accept(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer6<T4, T5, T6, T7, T8, T9> acceptPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8, v9) -> accept(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer5<T5, T6, T7, T8, T9> acceptPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8, v9) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer4<T6, T7, T8, T9> acceptPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8, v9) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer3<T7, T8, T9> acceptPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8, v9) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer2<T8, T9> acceptPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return (v8, v9) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8, v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer1<T9> acceptPartially(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + return (v9) -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), v9); + } + + /** + * Let this consumer partially accept the arguments. + */ + default Consumer0 acceptPartially(Tuple9<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9> args) { + return () -> accept(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9()); + } +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function0.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function0.java b/src/main/groovy/groovy/util/function/Function0.java new file mode 100644 index 0000000..4a2a219 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function0.java @@ -0,0 +1,69 @@ +/* + * 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.Tuple0; + +import java.util.function.Supplier; + +/** + * A function with 0 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function0<R> extends Supplier<R> { + + /** + * Apply this function to the arguments. + */ + default R apply() { + return get(); + } + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple0 args) { + return get(); + } + + /** + * Apply this function to the arguments. + */ + @Override + R get(); + + /** + * Convert this function to a {@link Supplier} + */ + default Supplier<R> toSupplier() { + return this::apply; + } + + /** + * Convert to this function from a {@link Supplier} + */ + static <R> Function0<R> from(Supplier<R> supplier) { + return supplier::get; + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function1.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function1.java b/src/main/groovy/groovy/util/function/Function1.java new file mode 100644 index 0000000..e1cc245 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function1.java @@ -0,0 +1,75 @@ +/* + * 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 java.util.function.Function; + +/** + * A function with 1 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function1<T1, R> extends Function<T1, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple1<? extends T1> args) { + return apply(args.v1()); + } + + /** + * Apply this function to the arguments. + */ + @Override + R apply(T1 v1); + + /** + * Convert this function to a {@link Function}. + */ + default Function<T1, R> toFunction() { + return this::apply; + } + + /** + * Convert to this function from a {@link Function}. + */ + static <T1, R> Function1<T1, R> from(Function<? super T1, ? extends R> function) { + return function::apply; + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(T1 v1) { + return () -> apply(v1); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<R> applyPartially(Tuple1<? extends T1> args) { + return () -> apply(args.v1()); + } +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function10.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function10.java b/src/main/groovy/groovy/util/function/Function10.java new file mode 100644 index 0000000..d05a0a8 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function10.java @@ -0,0 +1,195 @@ +/* + * 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.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 10 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(Tuple10<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9, ? extends T10> args) { + return apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10()); + } + + /** + * 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); + + /** + * Partially apply this function to the arguments. + */ + default Function9<T2, T3, T4, T5, T6, T7, T8, T9, T10, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T3, T4, T5, T6, T7, T8, T9, T10, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8, v9, v10) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T4, T5, T6, T7, T8, T9, T10, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8, v9, v10) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T5, T6, T7, T8, T9, T10, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8, v9, v10) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T6, T7, T8, T9, T10, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8, v9, v10) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T7, T8, T9, T10, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8, v9, v10) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T8, T9, T10, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8, v9, v10) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T9, T10, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return (v9, v10) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T10, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) { + return (v10) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * 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) { + return () -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T2, T3, T4, T5, T6, T7, T8, T9, T10, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10) -> apply(args.v1(), v2, v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T3, T4, T5, T6, T7, T8, T9, T10, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8, v9, v10) -> apply(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T4, T5, T6, T7, T8, T9, T10, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8, v9, v10) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T5, T6, T7, T8, T9, T10, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8, v9, v10) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T6, T7, T8, T9, T10, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8, v9, v10) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T7, T8, T9, T10, R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8, v9, v10) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T8, T9, T10, R> applyPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return (v8, v9, v10) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8, v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T9, T10, R> applyPartially(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + return (v9, v10) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), v9, v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T10, R> applyPartially(Tuple9<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8, ? extends T9> args) { + return (v10) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), v10); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<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 () -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function11.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function11.java b/src/main/groovy/groovy/util/function/Function11.java new file mode 100644 index 0000000..38d5286 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function11.java @@ -0,0 +1,210 @@ +/* + * 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.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 11 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(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 apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11()); + } + + /** + * 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); + + /** + * Partially apply this function to the arguments. + */ + default Function10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T3, T4, T5, T6, T7, T8, T9, T10, T11, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T4, T5, T6, T7, T8, T9, T10, T11, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8, v9, v10, v11) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T5, T6, T7, T8, T9, T10, T11, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8, v9, v10, v11) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T6, T7, T8, T9, T10, T11, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8, v9, v10, v11) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T7, T8, T9, T10, T11, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8, v9, v10, v11) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T8, T9, T10, T11, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8, v9, v10, v11) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T9, T10, T11, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return (v9, v10, v11) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T10, T11, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) { + return (v10, v11) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T11, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) { + return (v11) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * 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) { + return () -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -> apply(args.v1(), v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T3, T4, T5, T6, T7, T8, T9, T10, T11, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11) -> apply(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T4, T5, T6, T7, T8, T9, T10, T11, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8, v9, v10, v11) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T5, T6, T7, T8, T9, T10, T11, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8, v9, v10, v11) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T6, T7, T8, T9, T10, T11, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8, v9, v10, v11) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T7, T8, T9, T10, T11, R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8, v9, v10, v11) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T8, T9, T10, T11, R> applyPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return (v8, v9, v10, v11) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8, v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T9, T10, T11, R> applyPartially(Tuple8<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7, ? extends T8> args) { + return (v9, v10, v11) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), v9, v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T10, T11, 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) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), v10, v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T11, 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) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), v11); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<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 () -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function12.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function12.java b/src/main/groovy/groovy/util/function/Function12.java new file mode 100644 index 0000000..b7bae15 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function12.java @@ -0,0 +1,225 @@ +/* + * 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.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 12 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(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 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()); + } + + /** + * 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); + + /** + * Partially apply this function to the arguments. + */ + default Function11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T4, T5, T6, T7, T8, T9, T10, T11, T12, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8, v9, v10, v11, v12) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T5, T6, T7, T8, T9, T10, T11, T12, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8, v9, v10, v11, v12) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T6, T7, T8, T9, T10, T11, T12, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8, v9, v10, v11, v12) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T7, T8, T9, T10, T11, T12, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8, v9, v10, v11, v12) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T8, T9, T10, T11, T12, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8, v9, v10, v11, v12) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T9, T10, T11, T12, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return (v9, v10, v11, v12) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T10, T11, T12, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) { + return (v10, v11, v12) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T11, T12, 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) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T12, 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) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * 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) { + return () -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -> apply(args.v1(), v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -> apply(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T4, T5, T6, T7, T8, T9, T10, T11, T12, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8, v9, v10, v11, v12) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T5, T6, T7, T8, T9, T10, T11, T12, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8, v9, v10, v11, v12) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T6, T7, T8, T9, T10, T11, T12, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8, v9, v10, v11, v12) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T7, T8, T9, T10, T11, T12, R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8, v9, v10, v11, v12) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T8, T9, T10, T11, T12, R> applyPartially(Tuple7<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6, ? extends T7> args) { + return (v8, v9, v10, v11, v12) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8, v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T9, T10, T11, T12, 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) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), v9, v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T10, T11, T12, 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) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), v10, v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T11, T12, 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) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), v11, v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T12, 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) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), args.v11(), v12); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<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 () -> 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()); + } + +} http://git-wip-us.apache.org/repos/asf/groovy/blob/3ac1abcd/src/main/groovy/groovy/util/function/Function13.java ---------------------------------------------------------------------- diff --git a/src/main/groovy/groovy/util/function/Function13.java b/src/main/groovy/groovy/util/function/Function13.java new file mode 100644 index 0000000..fdadc58 --- /dev/null +++ b/src/main/groovy/groovy/util/function/Function13.java @@ -0,0 +1,240 @@ +/* + * 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.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 13 arguments. + * + * @since 3.0.0 + */ +@FunctionalInterface +public interface Function13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R> { + + /** + * Apply this function to the arguments. + * + * @param args The arguments as a tuple. + */ + default R apply(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 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()); + } + + /** + * 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); + + /** + * Partially apply this function to the arguments. + */ + default Function12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(T1 v1) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function11<T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(T1 v1, T2 v2) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(T1 v1, T2 v2, T3 v3) { + return (v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T5, T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4) { + return (v5, v6, v7, v8, v9, v10, v11, v12, v13) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { + return (v6, v7, v8, v9, v10, v11, v12, v13) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T7, T8, T9, T10, T11, T12, T13, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) { + return (v7, v8, v9, v10, v11, v12, v13) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T8, T9, T10, T11, T12, T13, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) { + return (v8, v9, v10, v11, v12, v13) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T9, T10, T11, T12, T13, R> applyPartially(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return (v9, v10, v11, v12, v13) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T10, T11, T12, T13, 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) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T11, T12, T13, 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) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T12, T13, 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) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T13, 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) -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * 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) { + return () -> apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(Tuple1<? extends T1> args) { + return (v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -> apply(args.v1(), v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function11<T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(Tuple2<? extends T1, ? extends T2> args) { + return (v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -> apply(args.v1(), args.v2(), v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function10<T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(Tuple3<? extends T1, ? extends T2, ? extends T3> args) { + return (v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -> apply(args.v1(), args.v2(), args.v3(), v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function9<T5, T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(Tuple4<? extends T1, ? extends T2, ? extends T3, ? extends T4> args) { + return (v5, v6, v7, v8, v9, v10, v11, v12, v13) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), v5, v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function8<T6, T7, T8, T9, T10, T11, T12, T13, R> applyPartially(Tuple5<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5> args) { + return (v6, v7, v8, v9, v10, v11, v12, v13) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), v6, v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function7<T7, T8, T9, T10, T11, T12, T13, R> applyPartially(Tuple6<? extends T1, ? extends T2, ? extends T3, ? extends T4, ? extends T5, ? extends T6> args) { + return (v7, v8, v9, v10, v11, v12, v13) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), v7, v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function6<T8, T9, T10, T11, T12, T13, 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) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), v8, v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function5<T9, T10, T11, T12, T13, 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) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), v9, v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function4<T10, T11, T12, T13, 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) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), v10, v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function3<T11, T12, T13, 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) -> apply(args.v1(), args.v2(), args.v3(), args.v4(), args.v5(), args.v6(), args.v7(), args.v8(), args.v9(), args.v10(), v11, v12, v13); + } + + /** + * Partially apply this function to the arguments. + */ + default Function2<T12, T13, 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) -> 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); + } + + /** + * Partially apply this function to the arguments. + */ + default Function1<T13, 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) -> 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); + } + + /** + * Partially apply this function to the arguments. + */ + default Function0<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 () -> 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()); + } + +}