/** * Compares this object with the specified object for order. * This implementation is generally consistent with the implementation of * {@link #equals(Object)}, but consistency is not complete due to * awkwardness of comparison of {@code Properties} instances. * (check source for implementation details). * @param cpm ConnectionPoolManager to which to compare this instance */ @Override public int compareTo(ConnectionPoolManager cpm) { if (cpm == null) throw new NullPointerException("Invalid pool manager specified: null"); int i = this.name.compareTo(cpm.getName()); if (i != 0) return i; if (source instanceof String) i = ((String)source).compareTo(((String)cpm.source)); else if (source instanceof File) i = ((File)source).compareTo(((File)cpm.source)); else if (source instanceof Properties) { Properties p1 = (Properties)source; Properties p2 = (Properties)cpm.source; i = Integer.valueOf(p2.size()).compareTo(Integer.valueOf(p1.size())); } return i; }