Skip to content

Commit 3fb3963

Browse files
gselzerctrueden
authored andcommitted
Create Functions through Function9
A Function9 will be needed for the Create Ops.
1 parent e3ef2a0 commit 3fb3963

8 files changed

Lines changed: 664 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package org.scijava.ops.core;
2+
3+
import java.util.Objects;
4+
import java.util.function.Consumer;
5+
6+
/**
7+
* Represents an operation that accepts nine input arguments and returns no
8+
* result. This is the nine-arity specialization of {@link Consumer}. Unlike most
9+
* other functional interfaces, {@code Consumer9} is expected to operate via
10+
* side-effects.
11+
*
12+
* <p>
13+
* This is a <a href="package-summary.html">functional interface</a> whose
14+
* functional method is {@link #accept(Object, Object)}.
15+
*
16+
* @param <T>
17+
* the type of the first argument to the operation
18+
* @param <U>
19+
* the type of the second argument to the operation
20+
* @param <V>
21+
* the type of the third argument to the operation
22+
* @param <W>
23+
* the type of the fourth argument to the operation
24+
* @param <X>
25+
* the type of the fifth argument to the operation
26+
* @param <Y>
27+
* the type of the sixth argument to the operation
28+
* @param <Z>
29+
* the type of the seventh argument to the operation
30+
* @param <A>
31+
* the type of the eighth argument to the operation
32+
* @param <B>
33+
* the type of the ninth argument to the operation
34+
* @param <C>
35+
* the type of the tenth argument to the operation
36+
*
37+
* @see Consumer
38+
* @since 1.8
39+
*/
40+
@FunctionalInterface
41+
public interface Consumer10<T, U, V, W, X, Y, Z, A, B, C> {
42+
43+
/**
44+
* Performs this operation on the given arguments.
45+
*
46+
* @param t
47+
* the first input argument
48+
* @param u
49+
* the second input argument
50+
* @param v
51+
* the third input argument
52+
* @param w
53+
* the fourth input argument
54+
* @param x
55+
* the fifth input argument
56+
* @param y
57+
* the sixth input argument
58+
* @param z
59+
* the seventh input argument
60+
* @param a
61+
* the eighth input argument
62+
* @param b
63+
* the ninth input argument
64+
* @param c
65+
* the tenth input argument
66+
*/
67+
void accept(T t, U u, V v, W w, X x, Y y, Z z, A a, B b, C c);
68+
69+
/**
70+
* Returns a composed {@code Consumer9} that performs, in sequence, this
71+
* operation followed by the {@code after} operation. If performing either
72+
* operation throws an exception, it is relayed to the caller of the composed
73+
* operation. If performing this operation throws an exception, the
74+
* {@code after} operation will not be performed.
75+
*
76+
* @param after
77+
* the operation to perform after this operation
78+
* @return a composed {@code Consumer9} that performs in sequence this
79+
* operation followed by the {@code after} operation
80+
* @throws NullPointerException
81+
* if {@code after} is null
82+
*/
83+
default Consumer10<T, U, V, W, X, Y, Z, A, B, C> andThen(
84+
Consumer10<? super T, ? super U, ? super V, ? super W, ? super X, ? super Y, ? super Z, ? super A, ? super B, ? super C> after) {
85+
Objects.requireNonNull(after);
86+
87+
return (t, u, v, w, x, y, z, a, b, c) -> {
88+
accept(t, u, v, w, x, y, z, a, b, c);
89+
after.accept(t, u, v, w, x, y, z, a, b, c);
90+
};
91+
}
92+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package org.scijava.ops.core;
2+
3+
import java.util.Objects;
4+
import java.util.function.Consumer;
5+
6+
/**
7+
* Represents an operation that accepts five input arguments and returns no
8+
* result. This is the six-arity specialization of {@link Consumer}. Unlike most
9+
* other functional interfaces, {@code Consumer7} is expected to operate via
10+
* side-effects.
11+
*
12+
* <p>
13+
* This is a <a href="package-summary.html">functional interface</a> whose
14+
* functional method is {@link #accept(Object, Object)}.
15+
*
16+
* @param <T>
17+
* the type of the first argument to the operation
18+
* @param <U>
19+
* the type of the second argument to the operation
20+
* @param <V>
21+
* the type of the third argument to the operation
22+
* @param <W>
23+
* the type of the fourth argument to the operation
24+
* @param <X>
25+
* the type of the fifth argument to the operation
26+
* @param <Y>
27+
* the type of the sixth argument to the operation
28+
* @param <Z>
29+
* the type of the seventh argument to the operation
30+
*
31+
* @see Consumer
32+
* @since 1.8
33+
*/
34+
@FunctionalInterface
35+
public interface Consumer7<T, U, V, W, X, Y, Z> {
36+
37+
/**
38+
* Performs this operation on the given arguments.
39+
*
40+
* @param t
41+
* the first input argument
42+
* @param u
43+
* the second input argument
44+
* @param v
45+
* the third input argument
46+
* @param w
47+
* the fourth input argument
48+
* @param x
49+
* the fifth input argument
50+
* @param y
51+
* the sixth input argument
52+
* @param z
53+
* the seventh input argument
54+
*/
55+
void accept(T t, U u, V v, W w, X x, Y y, Z z);
56+
57+
/**
58+
* Returns a composed {@code Consumer7} that performs, in sequence, this
59+
* operation followed by the {@code after} operation. If performing either
60+
* operation throws an exception, it is relayed to the caller of the composed
61+
* operation. If performing this operation throws an exception, the
62+
* {@code after} operation will not be performed.
63+
*
64+
* @param after
65+
* the operation to perform after this operation
66+
* @return a composed {@code Consumer7} that performs in sequence this
67+
* operation followed by the {@code after} operation
68+
* @throws NullPointerException
69+
* if {@code after} is null
70+
*/
71+
default Consumer7<T, U, V, W, X, Y, Z> andThen(
72+
Consumer7<? super T, ? super U, ? super V, ? super W, ? super X, ? super Y, ? super Z> after) {
73+
Objects.requireNonNull(after);
74+
75+
return (t, u, v, w, x, y, z) -> {
76+
accept(t, u, v, w, x, y, z);
77+
after.accept(t, u, v, w, x, y, z);
78+
};
79+
}
80+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package org.scijava.ops.core;
2+
3+
import java.util.Objects;
4+
import java.util.function.Consumer;
5+
6+
/**
7+
* Represents an operation that accepts eight input arguments and returns no
8+
* result. This is the eight-arity specialization of {@link Consumer}. Unlike most
9+
* other functional interfaces, {@code Consumer8} is expected to operate via
10+
* side-effects.
11+
*
12+
* <p>
13+
* This is a <a href="package-summary.html">functional interface</a> whose
14+
* functional method is {@link #accept(Object, Object)}.
15+
*
16+
* @param <T>
17+
* the type of the first argument to the operation
18+
* @param <U>
19+
* the type of the second argument to the operation
20+
* @param <V>
21+
* the type of the third argument to the operation
22+
* @param <W>
23+
* the type of the fourth argument to the operation
24+
* @param <X>
25+
* the type of the fifth argument to the operation
26+
* @param <Y>
27+
* the type of the sixth argument to the operation
28+
* @param <Z>
29+
* the type of the seventh argument to the operation
30+
* @param <A>
31+
* the type of the eighth argument to the operation
32+
*
33+
* @see Consumer
34+
* @since 1.8
35+
*/
36+
@FunctionalInterface
37+
public interface Consumer8<T, U, V, W, X, Y, Z, A> {
38+
39+
/**
40+
* Performs this operation on the given arguments.
41+
*
42+
* @param t
43+
* the first input argument
44+
* @param u
45+
* the second input argument
46+
* @param v
47+
* the third input argument
48+
* @param w
49+
* the fourth input argument
50+
* @param x
51+
* the fifth input argument
52+
* @param y
53+
* the sixth input argument
54+
* @param z
55+
* the seventh input argument
56+
* @param a
57+
* the eighth input argument
58+
*/
59+
void accept(T t, U u, V v, W w, X x, Y y, Z z, A a);
60+
61+
/**
62+
* Returns a composed {@code Consumer8} that performs, in sequence, this
63+
* operation followed by the {@code after} operation. If performing either
64+
* operation throws an exception, it is relayed to the caller of the composed
65+
* operation. If performing this operation throws an exception, the
66+
* {@code after} operation will not be performed.
67+
*
68+
* @param after
69+
* the operation to perform after this operation
70+
* @return a composed {@code Consumer8} that performs in sequence this
71+
* operation followed by the {@code after} operation
72+
* @throws NullPointerException
73+
* if {@code after} is null
74+
*/
75+
default Consumer8<T, U, V, W, X, Y, Z, A> andThen(
76+
Consumer8<? super T, ? super U, ? super V, ? super W, ? super X, ? super Y, ? super Z, ? super A> after) {
77+
Objects.requireNonNull(after);
78+
79+
return (t, u, v, w, x, y, z, a) -> {
80+
accept(t, u, v, w, x, y, z, a);
81+
after.accept(t, u, v, w, x, y, z, a);
82+
};
83+
}
84+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package org.scijava.ops.core;
2+
3+
import java.util.Objects;
4+
import java.util.function.Consumer;
5+
6+
/**
7+
* Represents an operation that accepts nine input arguments and returns no
8+
* result. This is the nine-arity specialization of {@link Consumer}. Unlike most
9+
* other functional interfaces, {@code Consumer9} is expected to operate via
10+
* side-effects.
11+
*
12+
* <p>
13+
* This is a <a href="package-summary.html">functional interface</a> whose
14+
* functional method is {@link #accept(Object, Object)}.
15+
*
16+
* @param <T>
17+
* the type of the first argument to the operation
18+
* @param <U>
19+
* the type of the second argument to the operation
20+
* @param <V>
21+
* the type of the third argument to the operation
22+
* @param <W>
23+
* the type of the fourth argument to the operation
24+
* @param <X>
25+
* the type of the fifth argument to the operation
26+
* @param <Y>
27+
* the type of the sixth argument to the operation
28+
* @param <Z>
29+
* the type of the seventh argument to the operation
30+
* @param <A>
31+
* the type of the eighth argument to the operation
32+
* @param <B>
33+
* the type of the ninth argument to the operation
34+
*
35+
* @see Consumer
36+
* @since 1.8
37+
*/
38+
@FunctionalInterface
39+
public interface Consumer9<T, U, V, W, X, Y, Z, A, B> {
40+
41+
/**
42+
* Performs this operation on the given arguments.
43+
*
44+
* @param t
45+
* the first input argument
46+
* @param u
47+
* the second input argument
48+
* @param v
49+
* the third input argument
50+
* @param w
51+
* the fourth input argument
52+
* @param x
53+
* the fifth input argument
54+
* @param y
55+
* the sixth input argument
56+
* @param z
57+
* the seventh input argument
58+
* @param a
59+
* the eighth input argument
60+
* @param b
61+
* the ninth input argument
62+
*/
63+
void accept(T t, U u, V v, W w, X x, Y y, Z z, A a, B b);
64+
65+
/**
66+
* Returns a composed {@code Consumer9} that performs, in sequence, this
67+
* operation followed by the {@code after} operation. If performing either
68+
* operation throws an exception, it is relayed to the caller of the composed
69+
* operation. If performing this operation throws an exception, the
70+
* {@code after} operation will not be performed.
71+
*
72+
* @param after
73+
* the operation to perform after this operation
74+
* @return a composed {@code Consumer9} that performs in sequence this
75+
* operation followed by the {@code after} operation
76+
* @throws NullPointerException
77+
* if {@code after} is null
78+
*/
79+
default Consumer9<T, U, V, W, X, Y, Z, A, B> andThen(
80+
Consumer9<? super T, ? super U, ? super V, ? super W, ? super X, ? super Y, ? super Z, ? super A, ? super B> after) {
81+
Objects.requireNonNull(after);
82+
83+
return (t, u, v, w, x, y, z, a, b) -> {
84+
accept(t, u, v, w, x, y, z, a, b);
85+
after.accept(t, u, v, w, x, y, z, a, b);
86+
};
87+
}
88+
}

0 commit comments

Comments
 (0)