我的代码如下:
private Comparator<Task> comparator = new Comparator<Task>() {
@Override
public int compare(Task lhs, Task rhs) {
if (lhs.isCompleted() != rhs.isCompleted()) {
if (lhs.isCompleted()) {
return 1;
} else {
return -1;
}
} else {
if (lhs.isMarked() != rhs.isMarked()) {
if (lhs.isMarked()) {
return -1;
} else {
return 1;
}
} else {
lTime.set(lhs.getCreatedTime());
rTime.set(rhs.getCreatedTime());
return Time.compare(lTime, rTime);
}
}
}
}
它抛出java.lang.IllegalArgumentException: Comparison method violates its general contract!
,我的问题是,我的方法违反了哪个合同?谢谢!