View Javadoc

1   package org.lsst.ccs.config;
2   
3   import java.util.Comparator;
4   
5   /**
6    * Two objects with the same ParameterPath are unique in their category.
7    * The method would be used to fetch an object in a <TT>Set</TT>
8    * using another <TT>PathObject</TT>
9    */
10  public interface PathObject {
11      public static final Comparator<PathObject> COMPARATOR = new Comparator<PathObject>() {
12          @Override
13          public int compare(PathObject pathObject, PathObject otherPathObject) {
14              String pathString = pathObject.getPath().toString() ;
15              String otherPathString = otherPathObject.getPath().toString() ;
16              if(pathString.startsWith("main/") && ! otherPathString.startsWith("main/")) {
17                  return -1 ;
18              }
19              if(otherPathString.startsWith("main/") && ! pathString.startsWith("main/")) {
20                  return 1 ;
21              }
22              return pathString.compareTo(otherPathString);
23          }
24      } ;
25      public ParameterPath getPath() ;
26  }