View Javadoc
1   // %1126721046260:hoplugins.commons.utils%
2   package hoplugins.commons.utils;
3   
4   import java.util.Collection;
5   import java.util.Comparator;
6   import java.util.SortedSet;
7   import java.util.TreeSet;
8   
9   /***
10   * List Utility class
11   *
12   * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
13   */
14  public final class ListUtil {
15      /***
16       * Private default constuctor to prevent class instantiation.
17       */
18      private ListUtil() {
19      }
20  
21      /***
22       * Sort the collection and returns a SortedSet
23       *
24       * @param beans Collection to be sorted
25       * @param comparator Comparator to be used
26       *
27       * @return a sorted set
28       */
29      public static SortedSet getSortedSet(Collection beans, Comparator comparator) {
30          final SortedSet set = new TreeSet(comparator);
31  
32          if ((beans != null) && (beans.size() > 0)) {
33              set.addAll(beans);
34          }
35  
36          return set;
37      }
38  }