package net.sf.jasperreports.engine.fill;

class JRDefaultFirstIncrementer extends JRAbstractExtendedIncrementer {
  private static final JRDefaultFirstIncrementer instance = new JRDefaultFirstIncrementer();
  
  public static JRDefaultFirstIncrementer getInstance() {
    return instance;
  }
  
  public Object initialValue() {
    return null;
  }
  
  public Object combine(JRCalculable calculable, JRCalculable calculableValue, AbstractValueProvider valueProvider) {
    if (!calculable.isInitialized())
      return calculable.getValue(); 
    if (!calculableValue.isInitialized())
      return calculableValue.getValue(); 
    return null;
  }
  
  public Object increment(JRCalculable calculable, Object expressionValue, AbstractValueProvider valueProvider) {
    if (calculable.isInitialized())
      return expressionValue; 
    return calculable.getIncrementedValue();
  }
}
