de.jaetzold.art
Class SensorStateDecider

java.lang.Object
  |
  +--de.jaetzold.art.SensorStateDecider
All Implemented Interfaces:
StateDecider

public class SensorStateDecider
extends Object
implements StateDecider

A StateDecider which delivers the value of the target-Sensor as the result to nextStateValue(double,double).

See Also:
Sensor

Constructor Summary
SensorStateDecider(Sensor targetSensor)
          Constructs a new StateDecider which always uses the value of the given Sensor as the next state.
SensorStateDecider(Sensor targetSensor, boolean events)
          Constructs a new StateDecider which always uses the value of the given Sensor as the next state.
 
Method Summary
 boolean isCacheable()
          Tells whether this instance will in the future produce the same state for the same value argument, independent of the actualState.
 double nextStateValue(double state, double value)
          The value returned is the one the target sensor currently has.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SensorStateDecider

public SensorStateDecider(Sensor targetSensor)
Constructs a new StateDecider which always uses the value of the given Sensor as the next state.
See Also:
StateDecider.nextStateValue(double,double)

SensorStateDecider

public SensorStateDecider(Sensor targetSensor,
                          boolean events)
Constructs a new StateDecider which always uses the value of the given Sensor as the next state. If events is true a SensorListener is registered by the Sensor and the value of the last received SensorEvent is cached to be the next state-value.
See Also:
StateDecider.nextStateValue(double,double)
Method Detail

isCacheable

public boolean isCacheable()
Description copied from interface: StateDecider
Tells whether this instance will in the future produce the same state for the same value argument, independent of the actualState. This can be false first and then true at a later time, but it is not legal to return false here after a return of true in the past, because the true answer before was wrong then.
Specified by:
isCacheable in interface StateDecider
Following copied from interface: de.jaetzold.util.StateDecider
Returns:
true if this instance guarantees, that any further call to nextStateValue() with the same value-argument returns the same state

nextStateValue

public double nextStateValue(double state,
                             double value)
The value returned is the one the target sensor currently has.
Specified by:
nextStateValue in interface StateDecider
Following copied from interface: de.jaetzold.util.StateDecider
See Also:
StateDecider.isCacheable()