View Javadoc

1   package com.google.code.jetm.maven.util;
2   
3   import java.io.Serializable;
4   import java.util.Comparator;
5   
6   import etm.core.aggregation.Aggregate;
7   
8   /**
9    * A {@link Comparator} that compares two {@link Aggregate} objects by their {@link Aggregate#getName()}; it will first do a case-insensitive comparison and, if the yields the same result, will return
10   * the case-sensitive comparison of their two names.
11   * 
12   * @author jrh3k5
13   * 
14   */
15  
16  public class AggregateComparator implements Comparator<Aggregate>, Serializable {
17      private static final long serialVersionUID = -7535778376868300149L;
18  
19      /**
20       * {@inheritDoc}
21       */
22      public int compare(Aggregate o1, Aggregate o2) {
23          final int caseIgnoreDiff = o1.getName().compareToIgnoreCase(o2.getName());
24          return caseIgnoreDiff == 0 ? o1.getName().compareTo(o2.getName()) : caseIgnoreDiff;
25      }
26  
27  }