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