66import org .scijava .ops .core .Op ;
77import org .scijava .ops .core .computer .BiComputer ;
88import org .scijava .ops .core .computer .Computer ;
9+ import org .scijava .ops .core .computer .Computer3 ;
10+ import org .scijava .ops .core .computer .Computer4 ;
11+ import org .scijava .ops .core .computer .Computer5 ;
12+ import org .scijava .ops .core .computer .NullaryComputer ;
913import org .scijava .ops .types .Nil ;
1014import org .scijava .util .Types ;
1115
@@ -18,8 +22,25 @@ private Computers() {
1822 // NB: Prevent instantiation of utility class.
1923 }
2024
21- public static <I , O > Computer <I , O > unary (final OpService ops , final String opName ,
22- final Nil <I > inputType , final Nil <O > outputType , final Object ... secondaryArgs ) {
25+ public static <O > NullaryComputer <O > nullary (final OpService ops , final String opName , final Nil <O > outputType ,
26+ final Object ... secondaryArgs ) {
27+ Nil <NullaryComputer <O >> computerNil = new Nil <NullaryComputer <O >>() {
28+ @ Override
29+ public Type getType () {
30+ return Types .parameterize (NullaryComputer .class , new Type [] { outputType .getType () });
31+ }
32+ };
33+
34+ return ops .findOp ( //
35+ opName , //
36+ computerNil , //
37+ new Nil [] { outputType }, //
38+ new Nil [] { outputType }, //
39+ secondaryArgs );
40+ }
41+
42+ public static <I , O > Computer <I , O > unary (final OpService ops , final String opName , final Nil <I > inputType ,
43+ final Nil <O > outputType , final Object ... secondaryArgs ) {
2344
2445 Nil <Computer <I , O >> computerNil = new Nil <Computer <I , O >>() {
2546 @ Override
@@ -56,4 +77,65 @@ public Type getType() {
5677 secondaryArgs );
5778 }
5879
80+ public static <I1 , I2 , I3 , O > Computer3 <I1 , I2 , I3 , O > ternary (final OpService ops , final String opName ,
81+ final Nil <I1 > input1Type , final Nil <I2 > input2Type , final Nil <I3 > input3Type , final Nil <O > outputType ,
82+ final Object ... secondaryArgs ) {
83+
84+ Nil <Computer3 <I1 , I2 , I3 , O >> computerNil = new Nil <Computer3 <I1 , I2 , I3 , O >>() {
85+ @ Override
86+ public Type getType () {
87+ return Types .parameterize (Computer3 .class , new Type [] { input1Type .getType (), input2Type .getType (),
88+ input3Type .getType (), outputType .getType () });
89+ }
90+ };
91+
92+ return ops .findOp ( //
93+ opName , //
94+ computerNil , //
95+ new Nil [] { input1Type , input2Type , input3Type , outputType }, //
96+ new Nil [] { outputType }, //
97+ secondaryArgs );
98+ }
99+
100+ public static <I1 , I2 , I3 , I4 , O > Computer4 <I1 , I2 , I3 , I4 , O > quaternary (final OpService ops , final String opName ,
101+ final Nil <I1 > input1Type , final Nil <I2 > input2Type , final Nil <I3 > input3Type , final Nil <I4 > input4Type ,
102+ final Nil <O > outputType , final Object ... secondaryArgs ) {
103+
104+ Nil <Computer4 <I1 , I2 , I3 , I4 , O >> computerNil = new Nil <Computer4 <I1 , I2 , I3 , I4 , O >>() {
105+ @ Override
106+ public Type getType () {
107+ return Types .parameterize (Computer4 .class , new Type [] { input1Type .getType (), input2Type .getType (),
108+ input3Type .getType (), input4Type .getType (), outputType .getType () });
109+ }
110+ };
111+
112+ return ops .findOp ( //
113+ opName , //
114+ computerNil , //
115+ new Nil [] { input1Type , input2Type , input3Type , input4Type , outputType }, //
116+ new Nil [] { outputType }, //
117+ secondaryArgs );
118+ }
119+
120+ public static <I1 , I2 , I3 , I4 , I5 , O > Computer5 <I1 , I2 , I3 , I4 , I5 , O > quinary (final OpService ops ,
121+ final String opName , final Nil <I1 > input1Type , final Nil <I2 > input2Type , final Nil <I3 > input3Type ,
122+ final Nil <I4 > input4Type , final Nil <I5 > input5Type , final Nil <O > outputType ,
123+ final Object ... secondaryArgs ) {
124+
125+ Nil <Computer5 <I1 , I2 , I3 , I4 , I5 , O >> computerNil = new Nil <Computer5 <I1 , I2 , I3 , I4 , I5 , O >>() {
126+ @ Override
127+ public Type getType () {
128+ return Types .parameterize (Computer5 .class , new Type [] { input1Type .getType (), input2Type .getType (),
129+ input3Type .getType (), input4Type .getType (), input5Type .getType (), outputType .getType () });
130+ }
131+ };
132+
133+ return ops .findOp ( //
134+ opName , //
135+ computerNil , //
136+ new Nil [] { input1Type , input2Type , input3Type , input4Type , input5Type , outputType }, //
137+ new Nil [] { outputType }, //
138+ secondaryArgs );
139+ }
140+
59141}
0 commit comments