package net.sf.jasperreports.engine.fill;

class JRFloatDistinctCountIncrementer extends JRAbstractExtendedIncrementer {
  private static JRFloatDistinctCountIncrementer mainInstance = new JRFloatDistinctCountIncrementer();
  
  public static JRFloatDistinctCountIncrementer getInstance() {
    return mainInstance;
  }
  
  public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
    DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(variable.getHelperVariable((byte)0));
    if (variable.isInitialized())
      holder.init(); 
    return new Float((float)holder.getCount());
  }
  
  public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
    DistinctCountHolder holder = (DistinctCountHolder)valueProvider.getValue(calculable.getHelperVariable((byte)0));
    return new Float((float)holder.getCount());
  }
  
  public Object initialValue() {
    return JRFloatIncrementerFactory.ZERO;
  }
}
