package net.sf.jasperreports.engine.fill;

class JRComparableLowestIncrementer extends JRAbstractExtendedIncrementer {
  private static JRComparableLowestIncrementer mainInstance = new JRComparableLowestIncrementer();
  
  public static JRComparableLowestIncrementer getInstance() {
    return mainInstance;
  }
  
  public Object increment(JRCalculable variable, Object expressionValue, AbstractValueProvider valueProvider) {
    Comparable value = (Comparable)variable.getIncrementedValue();
    Comparable newValue = (Comparable)expressionValue;
    if (value != null && !variable.isInitialized() && (newValue == null || value.compareTo(newValue) < 0))
      newValue = value; 
    return newValue;
  }
  
  public Object initialValue() {
    return null;
  }
}
