org.shapelogic.calculation
Class CalcComposition

java.lang.Object
  extended by org.shapelogic.calculation.CalcComposition

public class CalcComposition
extends java.lang.Object

Compose Calculations.
compose(calc1,calc0).invoke(x) == calc1.invoke(calc0.invoke(x))
So they are composed from the right.

Not sure how these would work with more complicated classes.
Say compose a Stream with another stream.
I think that this is a stream compose.
What about an CalcValue with a Calc1 I think that should give a CalcInvoke.
But this is ambiguous if added to this class.
So either give these a different name. Or add to a different class.
What makes this worse is that a Stream implementation is also both a Calc1 and a CalcValue.
So do not add this now.

Author:
Sami Badawi

Constructor Summary
CalcComposition()
           
 
Method Summary
static
<In0,In1,Out>
Calc1<In0,Out>
compose(Calc1<In1,Out> calc1, Calc1<In0,In1> calc0)
          Composition of calculations / closures with 1 input and 1 output.
static
<In0,In1,Out>
CalcIndex1<In0,Out>
compose(Calc1<In1,Out> calc1, CalcIndex1<In0,In1> calc0)
          Compose calculation with 1 input and one index and calculation with 1 input.
static
<In,Out> Calc0<Out>
compose(Calc1<In,Out> calc1, Calc0<In> calc0)
          Composition of calculations with 0 input and 1 input.
static
<In,Out> CalcIndex0<Out>
compose(Calc1<In,Out> calc1, CalcIndex0<In> calc0)
          Compose calculation with index and calculation with 1 input
static
<In0,In1,Out>
CalcIndex1<In0,Out>
compose(CalcIndex1<In1,Out> calc1, CalcIndex1<In0,In1> calc0)
          Compose 2 calculations with 1 input and one index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalcComposition

public CalcComposition()
Method Detail

compose

public static <In0,In1,Out> Calc1<In0,Out> compose(Calc1<In1,Out> calc1,
                                                   Calc1<In0,In1> calc0)
Composition of calculations / closures with 1 input and 1 output.

Type Parameters:
In0 -
In1 -
Out -
Parameters:
calc1 - second calculation
calc0 - first calculation
Returns:

compose

public static <In,Out> Calc0<Out> compose(Calc1<In,Out> calc1,
                                          Calc0<In> calc0)
Composition of calculations with 0 input and 1 input.

Type Parameters:
In -
Out -
Parameters:
calc1 -
calc0 -
Returns:

compose

public static <In,Out> CalcIndex0<Out> compose(Calc1<In,Out> calc1,
                                               CalcIndex0<In> calc0)
Compose calculation with index and calculation with 1 input

Type Parameters:
In -
Out -
Parameters:
calc1 -
calc0 -
Returns:

compose

public static <In0,In1,Out> CalcIndex1<In0,Out> compose(Calc1<In1,Out> calc1,
                                                        CalcIndex1<In0,In1> calc0)
Compose calculation with 1 input and one index and calculation with 1 input.

Type Parameters:
In0 -
In1 -
Out -
Parameters:
calc1 -
calc0 -
Returns:

compose

public static <In0,In1,Out> CalcIndex1<In0,Out> compose(CalcIndex1<In1,Out> calc1,
                                                        CalcIndex1<In0,In1> calc0)
Compose 2 calculations with 1 input and one index.

Type Parameters:
In0 -
In1 -
Out -
Parameters:
calc1 -
calc0 -
Returns:


Copyright © 2008. All Rights Reserved.