View Javadoc

1   /*
2    * $Id: PreferredComparator.java 20925 2011-01-06 19:53:34Z pablo.kraan $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.config;
12  
13  import java.util.Comparator;
14  
15  public class PreferredComparator implements Comparator<Preferred>
16  {
17  
18      public int compare(Preferred preferred1, Preferred preferred2)
19      {
20          if (preferred1 == null && preferred2 == null)
21          {
22              return 0;
23          }
24  
25          if (preferred1 != null && preferred2 == null)
26          {
27              return 1;
28          }
29  
30          if (preferred1 == null)
31          {
32              return -1;
33          }
34  
35          return new Integer(preferred1.weight()).compareTo(preferred2.weight());
36      }
37  }