ca.odell.glazedlists.calculation
Class AbstractCompositeCalculation<N extends Number>

java.lang.Object
  extended by ca.odell.glazedlists.calculation.AbstractCalculation<N>
      extended by ca.odell.glazedlists.calculation.AbstractCompositeCalculation<N>
All Implemented Interfaces:
Calculation<N>, PropertyChangeListener, EventListener

public abstract class AbstractCompositeCalculation<N extends Number>
extends AbstractCalculation<N>
implements PropertyChangeListener

Advanced Calculations can be derived by combining many smaller Calculations together using a formula. This abstract class advances toward the goal of combining multiple input Calculations using any arithmetic expression to produce the value of this calculation.

When any of the input Calculations change their value, this composite Calculation responds by recomputing its own value.

Author:
James Lemieux

Constructor Summary
protected AbstractCompositeCalculation(Calculation<? extends Number>... inputs)
          Combines the given inputs with the logic in recompute(java.lang.Number[]) to produce the value of this Calculation.
 
Method Summary
 void dispose()
          Cease the updating of this Calculation from its data sources and free them for garbage collection.
 void propertyChange(PropertyChangeEvent evt)
          When any of the input Calculations report a change, this composite calculation is also recalculated in response.
protected abstract  N recompute(Number[] inputs)
          Provides the logic to combine the inputs into the single numeric value of this composite calculation.
 
Methods inherited from class ca.odell.glazedlists.calculation.AbstractCalculation
addPropertyChangeListener, fireValueChange, getName, getValue, removePropertyChangeListener, setName, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCompositeCalculation

protected AbstractCompositeCalculation(Calculation<? extends Number>... inputs)
Combines the given inputs with the logic in recompute(java.lang.Number[]) to produce the value of this Calculation.

Parameters:
inputs - smaller Calculations to combine to produce this Calculation
Method Detail

dispose

public void dispose()
Description copied from interface: Calculation
Cease the updating of this Calculation from its data sources and free them for garbage collection.

Specified by:
dispose in interface Calculation<N extends Number>

recompute

protected abstract N recompute(Number[] inputs)
Provides the logic to combine the inputs into the single numeric value of this composite calculation. The inputs can be combined using any desirable arithmetic expression.

Parameters:
inputs - the values of the composed Calculations
Returns:
the single numeric value of this composite calculation

propertyChange

public void propertyChange(PropertyChangeEvent evt)
When any of the input Calculations report a change, this composite calculation is also recalculated in response.

Specified by:
propertyChange in interface PropertyChangeListener


Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by hbrands at 2017-03-13 22:58