package net.sf.jasperreports.engine.fill;

class JRComparableHighestIncrementer extends JRAbstractExtendedIncrementer {
  private static JRComparableHighestIncrementer mainInstance = new JRComparableHighestIncrementer();
  
  public static JRComparableHighestIncrementer 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;
  }
}
