/** * Returns the best candidate considering the this and the given other candidate. * * The result is not necessarily this or the other, but may also be a third instance, * e.g. in order to disambiguate certain error conditions. */ @Override public ILinkingCandidate getPreferredCandidate(ILinkingCandidate other) { if (other instanceof AbstractPendingLinkingCandidate) { AbstractPendingLinkingCandidate<?> right = (AbstractPendingLinkingCandidate<?>) other; CandidateCompareResult candidateCompareResult = compareTo(right); switch(candidateCompareResult) { case AMBIGUOUS: return createAmbiguousLinkingCandidate(right); case SUSPICIOUS_OTHER: return createSuspiciousLinkingCandidate(right); case EQUALLY_INVALID: case THIS: return this; case OTHER: return other; } } throw new IllegalArgumentException("other was " + other); }