@@ -98,10 +98,16 @@ public class OpBuilder {
9898
9999 private final OpEnvironment env;
100100 private final String opName;
101+ private final Hints hints;
101102
102103 public OpBuilder(final OpEnvironment env, final String opName) {
104+ this(env, opName, env.getDefaultHints());
105+ }
106+
107+ public OpBuilder(final OpEnvironment env, final String opName, final Hints hints) {
103108 this.env = env;
104109 this.opName = opName;
110+ this.hints = hints;
105111 }
106112
107113 /** Specifies an op that accepts no inputs—i.e., a nullary op. */
@@ -233,22 +239,6 @@ public class OpBuilder {
233239 Object.class));
234240 }
235241
236- /**
237- * As {@link #producer}, but match using the provided {@code Hints}.
238- */
239- public Producer<?> producer(final Hints hints) {
240- final Nil<Producer<Object>> specialType = new Nil<>() {
241-
242- @Override
243- public Type getType() {
244- return Types.parameterize(Producer.class, new Type[] {
245- Object.class });
246- }
247- };
248- return env.op(opName, specialType, new Nil<?>[0], Nil.of(
249- Object.class, hints));
250- }
251-
252242 /**
253243 * Match then immediately run a type-unsafe {@link org.scijava.function.Producer} op and get its output.
254244 *
@@ -264,13 +254,6 @@ public class OpBuilder {
264254 public Object create() {
265255 return producer().create();
266256 }
267-
268- /**
269- * As {@link #create}, but match using the provided {@code Hints}.
270- */
271- public Object create(final Hints hints) {
272- return producer(hints).create();
273- }
274257 }
275258
276259 /**
@@ -309,21 +292,6 @@ public class OpBuilder {
309292 return env.op(opName, specialType, new Nil<?>[0], outType);
310293 }
311294
312- /**
313- * As {@link #producer}, but match with the provided {@code Hints}.
314- */
315- public Producer<O> producer(final Hints hints) {
316- final Nil<Producer<O>> specialType = new Nil<>() {
317-
318- @Override
319- public Type getType() {
320- return Types.parameterize(Producer.class, new Type[] { outType
321- .getType() });
322- }
323- };
324- return env.op(opName, specialType, new Nil<?>[0], outType, hints);
325- }
326-
327295 /**
328296 * Match a {@link org.scijava.function.Computers} op, based on the choices made with this builder, for operating on pre-allocated output.
329297 *
@@ -335,14 +303,7 @@ public class OpBuilder {
335303 * @see <a href="#[[#producer()]]#" title="For a reusable Op to create objects of this builder's output type without re-matching.">producer</a>
336304 */
337305 public Computers.Arity0<O> computer() {
338- return matchComputer(env, opName, outType);
339- }
340-
341- /**
342- * As {@link #computer}, but match using the provided {@code Hints}.
343- */
344- public Computers.Arity0<O> computer(Hints hints) {
345- return matchComputer(env, opName, outType, hints);
306+ return matchComputer(env, opName, outType, OpBuilder.this.hints);
346307 }
347308
348309 /**
@@ -358,17 +319,6 @@ public class OpBuilder {
358319 public O create() {
359320 return producer().create();
360321 }
361-
362- /**
363- * As {@link #create}, but match using the provided {@code Hints}.
364- *
365- * @return The {@code O} created by this op
366- *
367- * @throws org.scijava.ops.api.features.OpMatchingException if the Op request cannot be satisfied.
368- */
369- public O create(Hints hints) {
370- return producer(hints).create();
371- }
372322 }
373323
374324 /**
@@ -395,14 +345,7 @@ public class OpBuilder {
395345 * @see <a href="#[[#compute()]]#" title="To match then immediately run a Computer Op using this builder's pre-allocated output.">compute</a>
396346 */
397347 public Computers.Arity0<O> computer() {
398- return matchComputer(env, opName, type(out));
399- }
400-
401- /**
402- * As {@link #computer}, but match using the provided {@code Hints}.
403- */
404- public Computers.Arity0<O> computer(final Hints hints) {
405- return matchComputer(env, opName, type(out), hints);
348+ return matchComputer(env, opName, type(out), OpBuilder.this.hints);
406349 }
407350
408351 /**
@@ -413,14 +356,6 @@ public class OpBuilder {
413356 public void compute() {
414357 computer().compute(out);
415358 }
416-
417- /**
418- * As {@link #compute}, but match using the provided {@code Hints}.
419- */
420- public void compute(final Hints hints) {
421- computer(hints).compute(out);
422- }
423-
424359 }
425360
426361#foreach($arity in $arities)
@@ -503,14 +438,7 @@ public class OpBuilder {
503438 * @see <a href="#[[#computer()]]#" title="For a reusable Op to process pre-allocated outputs without re-matching.">computer</a>
504439 */
505440 public $functionArity.call($arity)$generics.call($arity) function() {
506- return matchFunction(env, opName, $inputTypesWithOutput.call($arity));
507- }
508-
509- /**
510- * As {@link #function}, but match using the provided {@code Hints}.
511- */
512- public $functionArity.call($arity)$generics.call($arity) function(final Hints hints) {
513- return matchFunction(env, opName, $inputTypesWithOutput.call($arity), hints);
441+ return matchFunction(env, opName, $inputTypesWithOutput.call($arity), OpBuilder.this.hints);
514442 }
515443
516444 /**
@@ -523,16 +451,8 @@ public class OpBuilder {
523451 * @see <a href="#[[#function()]]#" title="For a reusable Op that generates output instances based on its inputs.">function</a>
524452 */
525453 public Computers.Arity${arity}$generics.call($arity) computer() {
526- return matchComputer(env, opName, $inputTypesWithOutput.call($arity));
527- }
528-
529- /**
530- * As {@link #computer}, but match using the provided {@code Hints}.
531- */
532- public Computers.Arity${arity}$generics.call($arity) computer(final Hints hints) {
533- return matchComputer(env, opName, $inputTypesWithOutput.call($arity), hints);
454+ return matchComputer(env, opName, $inputTypesWithOutput.call($arity), OpBuilder.this.hints);
534455 }
535-
536456 }
537457
538458 /**
@@ -590,14 +510,7 @@ public class OpBuilder {
590510 * @see <a href="#inplace#if ( $arity > 1 )1#end()" title="For a reusable Op that modifies a provided input parameter in-place.">inplace</a>
591511 */
592512 public $functionArity.call($arity)$genericsWildcardFunction.call($arity) function() {
593- return matchFunction(env, opName, $inputTypes.call($arity), Nil.of(Object.class));
594- }
595-
596- /**
597- * As {@link #function}, but match using the provided {@code Hints}.
598- */
599- public $functionArity.call($arity)$genericsWildcardFunction.call($arity) function(final Hints hints) {
600- return matchFunction(env, opName, $inputTypes.call($arity), Nil.of(Object.class), hints);
513+ return matchFunction(env, opName, $inputTypes.call($arity), Nil.of(Object.class), OpBuilder.this.hints);
601514 }
602515
603516#foreach($a in [1..$arity])
@@ -616,15 +529,6 @@ public class OpBuilder {
616529 return $matchName.call($arity, $a)(env, opName, $inputTypes.call($arity));
617530 }
618531
619- #end
620- #foreach($a in [1..$arity])
621- /**
622- * As {@link #inplace#if ( $arity > 1 )$a#end}, but match using the provided {@code Hints}.
623- */
624- public Inplaces.Arity$inplaceSuffix.call($arity, $a)$genericsWithoutOutput.call($arity) inplace${inplaceMatchNumber.call($arity, $a)}(final Hints hints) {
625- return $matchName.call($arity, $a)(env, opName, $inputTypes.call($arity), hints);
626- }
627-
628532#end
629533 }
630534
@@ -663,14 +567,7 @@ public class OpBuilder {
663567 * @see <a href="#[[#computer()]]#" title="For a reusable Op to process pre-allocated outputs without re-matching.">computer</a>
664568 */
665569 public $functionArity.call($arity)$generics.call($arity) function() {
666- return matchFunction(env, opName, $inputTypesFromArgs.call($arity), outType);
667- }
668-
669- /**
670- * As {@link #function}, but match using the provided {@code Hints}.
671- */
672- public $functionArity.call($arity)$generics.call($arity) function(final Hints hints) {
673- return matchFunction(env, opName, $inputTypesFromArgs.call($arity), outType, hints);
570+ return matchFunction(env, opName, $inputTypesFromArgs.call($arity), outType, OpBuilder.this.hints);
674571 }
675572
676573 /**
@@ -684,16 +581,9 @@ public class OpBuilder {
684581 * @see <a href="#[[#function()]]#" title="For a reusable Op that generates output instances based on its inputs.">function</a>
685582 */
686583 public Computers.Arity${arity}$generics.call($arity) computer() {
687- return matchComputer(env, opName, $inputTypesFromArgs.call($arity), outType);
584+ return matchComputer(env, opName, $inputTypesFromArgs.call($arity), outType, OpBuilder.this.hints );
688585 }
689586
690- /**
691- * As {@link #computer}, but match using the provided {@code Hints}.
692- */
693- public Computers.Arity${arity}$generics.call($arity) computer(final Hints hints) {
694- return matchComputer(env, opName, $inputTypesFromArgs.call($arity), outType, hints);
695- }
696-
697587 /**
698588 * Match then immediately run a {@link org.scijava.function.Functions} op and get its output.
699589 *
@@ -707,14 +597,6 @@ public class OpBuilder {
707597 public O apply() {
708598 return function().apply($inputObjects.call($arity));
709599 }
710-
711- /**
712- * As {@link #apply}, but match using the provided {@code Hints}.
713- */
714- public O apply(final Hints hints) {
715- return function(hints).apply($inputObjects.call($arity));
716- }
717-
718600 }
719601
720602 /**
@@ -796,14 +678,7 @@ public class OpBuilder {
796678 * @see <a href="#outType-org.scijava.types.Nil-" title="To specify the output type, preserving its generic parameters.">outType(Nil)</a>
797679 */
798680 public $functionArity.call($arity)$genericsWildcardFunction.call($arity) function() {
799- return matchFunction(env, opName, $inputTypesFromArgs.call($arity), Nil.of(Object.class));
800- }
801-
802- /**
803- * As {@link #function}, but match using the provided {@code Hints}.
804- */
805- public $functionArity.call($arity)$genericsWildcardFunction.call($arity) function(final Hints hints) {
806- return matchFunction(env, opName, $inputTypesFromArgs.call($arity), Nil.of(Object.class), hints);
681+ return matchFunction(env, opName, $inputTypesFromArgs.call($arity), Nil.of(Object.class), OpBuilder.this.hints);
807682 }
808683
809684#foreach($a in [1..$arity])
@@ -826,16 +701,6 @@ public class OpBuilder {
826701 return $matchName.call($arity, $a)(env, opName, $inputTypesFromArgs.call($arity));
827702 }
828703
829- #end
830- #foreach($a in [1..$arity])
831- /**
832- * As {@link #inplace#if ( $arity > 1 )$a#end}, but match using the provided {@code Hints}.
833- */
834- public Inplaces.Arity$inplaceSuffix.call($arity, $a)$genericsWithoutOutput.call($arity) inplace${inplaceMatchNumber.call($arity, $a)}(final Hints hints) {
835- checkInplaceRefs($a, $inputObjects.call($arity));
836- return $matchName.call($arity, $a)(env, opName, $inputTypesFromArgs.call($arity), hints);
837- }
838-
839704#end
840705 /**
841706 * Match then immediately run a type-unsafe {@link org.scijava.function.Functions} op and get its output.
@@ -855,13 +720,6 @@ public class OpBuilder {
855720 return function().apply($inputObjects.call($arity));
856721 }
857722
858- /**
859- * As {@link #apply}, but match using the provided {@code Hints}.
860- */
861- public Object apply(final Hints hints) {
862- return function(hints).apply($inputObjects.call($arity));
863- }
864-
865723#foreach($a in [1..$arity])
866724 /**
867725 * Match then immediately run an {@link org.scijava.function.Inplaces} op to mutate the $a#if ( $a == 1 )st#elseif ( $a == 2 )nd#elseif ( $a == 3 )rd#{else}th#end parameter.
@@ -877,15 +735,6 @@ public class OpBuilder {
877735 inplace${inplaceMatchNumber.call($arity, $a)}().mutate($inputObjects.call($arity));
878736 }
879737
880- #end
881- #foreach($a in [1..$arity])
882- /**
883- * As {@link #mutate#if ( $arity > 1 )$a#end}, but match using the provided {@code Hints}.
884- */
885- public void mutate${inplaceMatchNumber.call($arity, $a)}(final Hints hints) {
886- inplace${inplaceMatchNumber.call($arity, $a)}(hints).mutate($inputObjects.call($arity));
887- }
888-
889738#end
890739 }
891740
@@ -922,14 +771,7 @@ public class OpBuilder {
922771 * @see <a href="#[[#compute()]]#" title="To match then immediately run a Computer Op using this builder's pre-allocated output.">compute</a>
923772 */
924773 public Computers.Arity${arity}${generics.call($arity)} computer() {
925- return matchComputer(env, opName, $inputTypesFromArgs.call($arity), type(out));
926- }
927-
928- /**
929- * As {@link #computer}, but match using the provided {@code Hints}.
930- */
931- public Computers.Arity${arity}${generics.call($arity)} computer(final Hints hints) {
932- return matchComputer(env, opName, $inputTypesFromArgs.call($arity), type(out), hints);
774+ return matchComputer(env, opName, $inputTypesFromArgs.call($arity), type(out), OpBuilder.this.hints);
933775 }
934776
935777 /**
@@ -940,14 +782,6 @@ public class OpBuilder {
940782 public void compute() {
941783 computer().compute($inputObjects.call($arity), out);
942784 }
943-
944- /**
945- * As {@link #compute}, but match using the provided {@code Hints}.
946- */
947- public void compute(final Hints hints) {
948- computer(hints).compute($inputObjects.call($arity), out);
949- }
950-
951785 }
952786#end
953787
0 commit comments