View Javadoc

1   package com.atlassian.plugin.web.descriptors;
2   
3   import java.util.Comparator;
4   
5   /**
6    * A simple comparator for any weighted descriptor - lowest weights first.
7    */
8   public class WeightedDescriptorComparator implements Comparator
9   {
10      public int compare(Object o1, Object o2)
11      {
12          WeightedDescriptor w1 = (WeightedDescriptor)o1;
13          WeightedDescriptor w2 = (WeightedDescriptor)o2;
14          if (w1.getWeight() < w2.getWeight())
15              return -1;
16          else if (w1.getWeight() > w2.getWeight())
17              return 1;
18          else
19              return 0;
20      }
21  }