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

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

import de.ivu.elect.business.gebietsbaum.entity.Gebiet;
import de.ivu.elect.business.gebietsbaum.entity.Gebietsart;

public class GebietsartByPositionComparator implements Comparator<Gebietsart>, Serializable {

  public static final GebietsartByPositionComparator INSTANCE = new GebietsartByPositionComparator();

  private static final long serialVersionUID = 1L;

  /**
   * Not Null-Safe!
   *
   * @see Comparator#compare(Object, Object)
   */
  @Override
  public int compare(Gebietsart o1, Gebietsart o2) {
    int result = o1.getPosition().compareTo(o2.getPosition());

    if (result == 0) {
      result = o1.getPk().compareTo(o2.getPk());

    }
    return result;
  }

}
