- java.lang.Object
-
- org.scijava.ops.engine.impl.LambdaTypeBaker
-
public final class LambdaTypeBaker extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TbakeLambdaType(T originalOp, Type reifiedType)Used to enrich a lambda expression with its generic type.
-
-
-
Method Detail
-
bakeLambdaType
public static <T> T bakeLambdaType(T originalOp, Type reifiedType)Used to enrich a lambda expression with its generic type. Its usage is necessary in order to find Ops that could take this lamdba expression as an argument.Suppose, for example, that a user has written a lambda
Computers.Arity1<Double, Double> computer, but a user wishes to have aComputers.Arity1<Iterable<Double>, Iterable<Double>>. They know of an Op in theOpEnvironmentthat is able to adaptcomputerso that it is run in a parallel fashion. They cannot simply call
since the type parameters ofop("engine.adapt").input(computer).outType( new Nil<Computers.Arity1<Iterable<Double>, Iterable<Double>>>() {}).apply()computerare not retained at runtime.bakeLambdaTypeshould be used as a method of retaining that fully reified lambda type so that the lambda can be usedNote:
bakeLambdaTypedoes not need to be used with anonymous subclasses; these retain their type parameters at runtime. It is only lambda expressions that need to be passed to this method.- Type Parameters:
T- The type of the op instance to enrich.- Parameters:
originalOp- The op instance to enrich.reifiedType- The intended generic type of the object to be known at runtime.- Returns:
- An enriched version of the object with full knowledge of its generic type.
-
-