* @param o1 first ServletType object
* @param o2 second ServletType object
* @return an int < 0 if o1 precedes o2, 0 if they are equal, and > 0 if o2 preceeds o1.
*/
public int compare(Object o1, Object o2) {
ServletType s1 = (ServletType) o1;
ServletType s2 = (ServletType) o2;
// load-on-startup is set for neither. the
// ordering at this point doesn't matter, but we
// should return "0" only if the two objects say
// they are equal
if (!s1.isSetLoadOnStartup() && !s2.isSetLoadOnStartup()) {
return s1.equals(s2) ? 0 : s1.getServletName().getStringValue().trim().compareTo(s2.getServletName().getStringValue().trim());
}
// load-on-startup is set for one but not the
// other. whichever one is set will be "less
// than", i.e. it will be loaded first
if (s1.isSetLoadOnStartup() && !s2.isSetLoadOnStartup()) {
return -1;
}
if (!s1.isSetLoadOnStartup() && s2.isSetLoadOnStartup()) {
return 1;
}
// load-on-startup is set for both. whichever one
// has a smaller value is "less than"
int comp = s1.getLoadOnStartup().getBigIntegerValue().compareTo(s2.getLoadOnStartup().getBigIntegerValue());
if (comp == 0) {
return s1.getServletName().getStringValue().trim().compareTo(s2.getServletName().getStringValue().trim());
}
return comp;
}