View Javadoc
1   package com.atlassian.plugin;
2   
3   import java.io.Serializable;
4   import java.util.Comparator;
5   
6   /**
7    * Compares two plugins by their names
8    */
9   class PluginNameComparator implements Comparator<Plugin>, Serializable {
10      static final long serialVersionUID = -2595168544386708474L;
11  
12      /**
13       * Gets names of the two given plugins and returns the result of their comparison
14       *
15       * @param p1 plugin to compare
16       * @param p2 plugin to compare
17       * @return result of plugin name comparison
18       */
19      public int compare(final Plugin p1, final Plugin p2) {
20          final String name1 = p1.getName();
21          final String name2 = p2.getName();
22          if ((name1 == null) || (name2 == null)) {
23              return (name1 == null) ? (name2 == null) ? 0 : -1 : 1;
24          }
25          return name1.compareTo(name2);
26      }
27  }