- java.lang.Object
-
- org.scijava.ops.tutorial.WritingConciseOps
-
public class WritingConciseOps extends Object
WhileOpTypesshows how to write an Op as aClass, it is much more convenient to write Ops with less code. This tutorial shows how you can write Ops contained withinFields andMethods, leading to less boilerplate code!- Author:
- Gabriel Selzer, Mark Hiner
- See Also:
for information about writing Ops as es.
-
-
Field Summary
Fields Modifier and Type Field Description BiFunction<Double,Double,Double>opFieldPowerOne major benefit of Ops written asFields is that they can use Java's lambda syntax, maximizing expressiveness.
-
Constructor Summary
Constructors Constructor Description WritingConciseOps()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidmain(String... args)static DoubleopMethodPower(Double b, Double e)Ops can additionally be written asMethods.
-
-
-
Field Detail
-
opFieldPower
public final BiFunction<Double,Double,Double> opFieldPower
One major benefit of Ops written asFields is that they can use Java's lambda syntax, maximizing expressiveness. Field Ops must bepublicandfinal, and should define Op parameters using the following tags:@input <name> <description>to describe a parameter named<name>with purpose<description>@container <name> <description>to describe a preallocated output container parameter named<name>with purpose<description>@mutable <name> <description>to describe a mutable input parameter named<name>with purpose<description>@output <descriptionto describe a lambda return with purpose<description>
- Output parameters:
the- result- Input parameters:
b- the basee- the exponent- Implementation Note:
- op names="test.opField.power"
-
-
Method Detail
-
opMethodPower
public static Double opMethodPower(Double b, Double e)
Ops can additionally be written asMethods. Method Ops must bepublicandstatic, and should declare their parameters using the following tags:@param <name> <description>to describe a parameter named<name>with purpose<description>@param <name> <description> (container)to describe a preallocated output container parameter named<name>with purpose<description>@param <name> <description> (mutable)to describe a mutable input parameter named<name>with purpose<description>@return <descriptionto describe a method return with purpose<description>
- Parameters:
b- the basee- the exponent- Returns:
- the result
- Implementation Note:
- op names="test.opMethod.power"
-
main
public static void main(String... args)
-
-