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

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

import de.ivu.elect.business.gruppeimgebiet.entity.GruppeImGebiet;
import de.ivu.elect.business.stimmzettel.entity.AbstractEntityAufStimmzettelStimmzettelPosition;
import de.ivu.elect.util.NullComparator;

public class GruppeImGebietByRelativePositionComparator implements Comparator<GruppeImGebiet>, Serializable {

  private static final long serialVersionUID = 1L;

  public GruppeImGebietByRelativePositionComparator() {
    super();
  }

  @Override
  public int compare(GruppeImGebiet one, GruppeImGebiet another) {
    if (one == null || another == null) {
      return NullComparator.NON_NULL_BEFORE_NULL_COMPARATOR.compare(one, another);
    }

    return compareByPosition(one.getRelativePosition(), another.getRelativePosition());
  }

  public int compareByPosition(Long one, Long another) {
    return AbstractEntityAufStimmzettelStimmzettelPosition.DEFAULT_POSITION_COMPARATOR.compare(one, another);
  }
}
