Android Open Source - rights-alert Application Entity Comparator

From Project

Back to project page rights-alert.


The source code is released under:

GNU General Public License

If you think the Android project rights-alert listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fr.keuse.rightsalert.comparator;
//from   ww  w  . ja va2  s.c o  m
import java.util.Comparator;

import android.util.Log;

import fr.keuse.rightsalert.entity.ApplicationEntity;

public class ApplicationEntityComparator implements Comparator<ApplicationEntity> {
  private String sort;
  public ApplicationEntityComparator(String sort) {
    this.sort = sort;
  public int compare(ApplicationEntity lae, ApplicationEntity rae) {
      return scoreCompare(lae, rae);
    else if("name".equals(sort))
      return nameCompare(lae, rae);
    else {
      Log.w("error","Unknown sort type");
      return nameCompare(lae, rae);
  private int nameCompare(ApplicationEntity lae, ApplicationEntity rae) {
    return lae.getName().toLowerCase().compareTo(rae.getName().toLowerCase());
  private int scoreCompare(ApplicationEntity lae, ApplicationEntity rae) {
    Integer laeScore = lae.getScore();
    return laeScore.compareTo(rae.getScore());

Java Source Code List