cmp = lhs.getType().compareTo(rhs.getType()); if (cmp != 0) return cmp;
BugPattern lhsPattern = lhs.getBugPattern(); BugPattern rhsPattern = rhs.getBugPattern();  if (lhsPattern == null || rhsPattern == null) {      String lhsCode = getCode(lhs.getType()); String rhsCode = getCode(rhs.getType());  if ((cmp = lhsCode.compareTo(rhsCode)) != 0) { return cmp; } } else {       if ((cmp = lhsPattern.getAbbrev().compareTo(rhsPattern.getAbbrev())) != 0) return cmp; }
	public int compare(BugInstance lhs, BugInstance rhs) {		// Attributes of BugInstance.		// Compare type.		// Compare class and method annotations (ignoring line numbers).		// Compare field annotations.		int cmp;		cmp = lhs.getType().compareTo(rhs.getType());		if (cmp != 0) return cmp;/*		// Don't compare priority.		// This is something that can reasonably change		// from one release of FindBugs to anther.		cmp = lhs.getPriority() - rhs.getPriority();		if (cmp != 0) return cmp;*/		Iterator<BugAnnotation> lhsIter = new FilteringAnnotationIterator(lhs.annotationIterator());		Iterator<BugAnnotation> rhsIter = new FilteringAnnotationIterator(rhs.annotationIterator());		while (lhsIter.hasNext() && rhsIter.hasNext()) {			BugAnnotation lhsAnnotation = lhsIter.next();			BugAnnotation rhsAnnotation = rhsIter.next();			// Different annotation types obviously cannot be equal,			// so just compare by class name.			if (lhsAnnotation.getClass() != rhsAnnotation.getClass())				return lhsAnnotation.getClass().getName().compareTo(rhsAnnotation.getClass().getName());			if (lhsAnnotation.getClass() == ClassAnnotation.class ||			        lhsAnnotation.getClass() == MethodAnnotation.class ||			        lhsAnnotation.getClass() == FieldAnnotation.class) {				// ClassAnnotations, MethodAnnotations, and FieldAnnotations				// may all be compared directly.				cmp = lhsAnnotation.compareTo(rhsAnnotation);				if (cmp != 0) return cmp;			} else if (lhsAnnotation.getClass() == SourceLineAnnotation.class) {				// We assume that source lines may change, but source files				// and bytecode offsets will not.				SourceLineAnnotation lhsSource = (SourceLineAnnotation) lhsAnnotation;				SourceLineAnnotation rhsSource = (SourceLineAnnotation) rhsAnnotation;				cmp = lhsSource.getSourceFile().compareTo(rhsSource.getSourceFile());				if (cmp != 0) return cmp;				cmp = lhsSource.getStartBytecode() - rhsSource.getStartBytecode();				if (cmp != 0) return cmp;				cmp = lhsSource.getEndBytecode() - rhsSource.getEndBytecode();				if (cmp != 0) return cmp;			} else if (isBoring(lhsAnnotation)) {				throw new IllegalStateException("Impossible");			} else				throw new IllegalStateException("Unknown annotation type: " + lhsAnnotation.getClass().getName());		}		if (rhsIter.hasNext())			return -1;		else if (lhsIter.hasNext())			return 1;		else			return 0;	}