@Override public int compare(Literal l1, Literal l2) { if (l1 == l2) return 0; int c = l1.name.compareTo(l2.name); if (c != 0) return c; if (l1.isNegation != l2.isNegation) return l1.isNegation ? Integer.MAX_VALUE : Integer.MIN_VALUE; // same name, negation sign // check mode and temporal c = l1.mode.compareTo(l2.mode); if (c != 0) return c; if (isCheckTemporal) { c = null == temporalComparator ? DEFAULT_TEMPORAL_COMPARTOR.compare(l1.temporal, l2.temporal) : temporalComparator.compare(l1.temporal, l2.temporal); // System.out.println("literalComparator.checkTemporal:("+l1+","+l2+")="+c); if (c != 0) return c; // if (null == l1.temporal) { // if (null != l2.temporal) { // Temporal t2=l2.temporal; // if (Long.MIN_VALUE == t2.startTime) return Long.MAX_VALUE==t2.endTime?0 :Integer.MAX_VALUE; // return Integer.MIN_VALUE; // } // } else { // Temporal t1=l1.temporal; // if (null == l2.temporal) { // if (Long.MIN_VALUE == t1.startTime) return Long.MAX_VALUE==t1.endTime?0: Integer.MIN_VALUE; // return Integer.MAX_VALUE; // } else { // Temporal t2 = l2.temporal; // c = null == temporalComparator ? t1.compareTo(t2) : temporalComparator.compare(t1, t2); // if (c != 0) return c; // } // } } c = l1.predicates.length - l2.predicates.length; if (c != 0) return c; for (int i = 0; i < l1.predicates.length; i++) { if (!l1.isPredicateGrounded(i) && !l2.isPredicateGrounded(i)) { } else if (l1.isPredicateGrounded(i) && l2.isPredicateGrounded(i)) { c = l1.predicates[i].compareTo(l2.predicates[i]); if (c != 0) return c; } else { return l1.isPredicateGrounded(i) ? Integer.MAX_VALUE : Integer.MIN_VALUE; } } return 0; }