Comparator
使用 Netbeans 和 Weblogic 12c 从 Java 1.7 升级到 Java 1.8 后,我们在界面上遇到 servlet 编译错误。这些.jsp
文件在 Java 1.7 中运行良好。我已经阅读了其他类似的问题,但没有找到解决方案。我曾尝试检查 Weblogic Domain configuration JSP Compiler Backwards Compatible,但没有成功。编译器抱怨的方法是default
方法,因此不需要提及,对吗?Comparator
是否需要为 Java 8 重新编写实现的类?如果有,请指教。
错误
viewFundCites.jsp:151:11: The type compareFundedPrOrderedByPr must implement the inherited abstract method Comparator.thenComparing(Function, Comparator)
class compareFundedPrOrderedByPr implements Comparator {
^-----------------------^
代码
class compareFundedPrOrderedByPr implements Comparator {
public int compare (Object a, Object b) {
int ordering = 0;
FundCite itemA = (FundCite)a;
FundCite itemB = (FundCite)b;
if ((null == itemA) && (null == itemB)) {
ordering = 0;
} else if ((null == itemA.getPrName()) && (null == itemB.getPrName())) {
ordering = 0;
} else if (null == itemA.getPrName()) {
ordering = -1;
} else if (null == itemB.getPrName()) {
ordering = 1;
} else {
// Do primary sort by PR Name.
ordering = itemA.getPrName().compareTo(itemB.getPrName());
if (0 == ordering) {
// Do secondary sort by CLIN.
if ((null == itemA.getClin()) && (null == itemB.getClin())) {
ordering = 0;
} else if (null == itemA.getClin()) {
ordering = -1;
} else if (null == itemB.getClin()) {
ordering = 1;
} else {
ordering = itemA.getClin().compareTo(itemB.getClin());
}
}
}
return ordering;
}
}