Class WritingConciseOps


  • public class WritingConciseOps
    extends Object
    While OpTypes shows how to write an Op as a Class, it is much more convenient to write Ops with less code. This tutorial shows how you can write Ops contained within Fields and Methods, leading to less boilerplate code!
    Author:
    Gabriel Selzer, Mark Hiner
    See Also:
    for information about writing Ops as es.
    • Field Detail

      • opFieldPower

        public final BiFunction<Double,​Double,​Double> opFieldPower
        One major benefit of Ops written as Fields is that they can use Java's lambda syntax, maximizing expressiveness. Field Ops must be public and final, 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 <description to describe a lambda return with purpose <description>
        Output parameters:
        the - result
        Input parameters:
        b - the base
        e - the exponent
        Implementation Note:
        op names="test.opField.power"
    • Constructor Detail

      • WritingConciseOps

        public WritingConciseOps()
    • Method Detail

      • opMethodPower

        public static Double opMethodPower​(Double b,
                                           Double e)
        Ops can additionally be written as Methods. Method Ops must be public and static, 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 <description to describe a method return with purpose <description>
        Parameters:
        b - the base
        e - the exponent
        Returns:
        the result
        Implementation Note:
        op names="test.opMethod.power"
      • main

        public static void main​(String... args)