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

import java.util.Comparator;

import de.ivu.elect.business.person.control.EntityMitPersonendatenByNamenComparator;
import de.ivu.elect.business.person.entity.Personendaten;
import de.ivu.elect.business.personenpruefung.entity.PersonenKonflikt;

public class PersonenKonfliktByPersonendatenNamenComparator implements Comparator<PersonenKonflikt> {

  private static final Comparator<Personendaten> PERSONENDATEN_BY_NAMEN_COMPARATOR = new EntityMitPersonendatenByNamenComparator<>();

  public PersonenKonfliktByPersonendatenNamenComparator() {
    super();
  }

  @Override
  public int compare(PersonenKonflikt one, PersonenKonflikt another) {
    if (one != null && another != null) {
      return PERSONENDATEN_BY_NAMEN_COMPARATOR.compare(one.getPersonendaten(), another.getPersonendaten());
    }

    if (one == null) {
      if (another == null) {
        return 0;
      }

      return -1;
    }

    return 1;
  }
}
