
package de.ivu.elect.business.security;

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

import de.ivu.elect.jee.faces.Messages;
import de.ivu.elect.util.CaseAndDiacriticIgnoringComparator;

public class UseCasePermissionMessageComparator implements Comparator<UseCasePermission>, Serializable {

  private static final long serialVersionUID = 1L;

  private final Messages messages;

  public UseCasePermissionMessageComparator(Messages messages) {
    this.messages = messages;
  }

  @Override
  public int compare(UseCasePermission one, UseCasePermission another) {
    return compare(messages.lokalisiere(one), messages.lokalisiere(another));
  }

  private int compare(String one, String another) {
    return CaseAndDiacriticIgnoringComparator.DEFAULT_INSTANCE.compare(one, another);
  }
}
