
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 WahlByWahldatumDescAndPositionAscComparator implements Comparator<Wahl>, Serializable {

  private static final long serialVersionUID = 1L;

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

  public WahlByWahldatumDescAndPositionAscComparator() {
    super();
  }

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

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

    return result;
  }
}
