
package de.ivu.elect.business.wahl.control;

import java.io.Serializable;
import java.util.Comparator;

import de.ivu.elect.business.wahl.entity.Wahl;

public class WahlByWahldatumAscAndPositionAscComparator implements Comparator<Wahl>, Serializable {

  private static final long serialVersionUID = 1L;

  private static final Comparator<Wahl> POSITION_COMPARATOR = new WahlByPositionComparator();

  public WahlByWahldatumAscAndPositionAscComparator() {
    super();
  }

  @Override
  public int compare(Wahl one, Wahl another) {
    int result = one.getWahldatum().compareTo(another.getWahldatum());

    if (result == 0) {
      result = POSITION_COMPARATOR.compare(one, another);
    }

    return result;
  }
}
