package net.sf.jasperreports.engine.fill;

class JRFloatCountIncrementer extends JRAbstractExtendedIncrementer {
  private static JRFloatCountIncrementer mainInstance = new JRFloatCountIncrementer();
  
  public static JRFloatCountIncrementer getInstance() {
    return mainInstance;
  }
  
  public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
    Number value = (Number)variable.getIncrementedValue();
    if (value == null || variable.isInitialized())
      value = JRFloatIncrementerFactory.ZERO; 
    if (expressionValue == null)
      return value; 
    return new Float(value.floatValue() + 1.0F);
  }
  
  public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
    Number value = (Number)calculable.getIncrementedValue();
    Number combineValue = (Number)calculableValue.getValue();
    if (value == null || calculable.isInitialized())
      value = JRFloatIncrementerFactory.ZERO; 
    if (combineValue == null)
      return value; 
    return new Float(value.floatValue() + combineValue.floatValue());
  }
  
  public Object initialValue() {
    return JRFloatIncrementerFactory.ZERO;
  }
}
