/** * Returns an {@link Iterator} over a {@link Collection} of Throwable types which iterates over its elements in a * consistent order (maintaining an ordering that is consistent across different runs makes it easier to compare sets * generated by different implementations of the CFG classes). * * @param coll * The collection to iterate over. * * @return An iterator which presents the elements of <code>coll</code> in order. */ private static <T extends RefLikeType> Iterator<T> sortedThrowableIterator(Collection<T> coll) { if (coll.size() <= 1) { return coll.iterator(); } else { @SuppressWarnings("unchecked") T[] array = (T[]) coll.toArray(new RefLikeType[coll.size()]); Arrays.sort(array, new ThrowableComparator<T>()); return Arrays.asList(array).iterator(); } }
public int compare(Object o1, Object o2) { RefType t1 = baseType(o1); RefType t2 = baseType(o2); if (t1.equals(t2)) { // There should never be both AnySubType(t) and // t in a ThrowableSet, but if it happens, put // AnySubType(t) first: if (o1 instanceof AnySubType) { if (o2 instanceof AnySubType) { return 0; } else { return -1; } } else if (o2 instanceof AnySubType) { return 1; } else { return 0; } } else { return t1.toString().compareTo(t2.toString()); } }
/** * Returns an {@link Iterator} over a {@link Collection} of * Throwable types which iterates over its elements in a * consistent order (maintaining an ordering that is consistent * across different runs makes it easier to compare sets generated * by different implementations of the CFG classes). * * @param coll The collection to iterate over. * * @return An iterator which presents the elements of <code>coll</code> * in order. */ private static Iterator sortedThrowableIterator(Collection coll) { if (coll.size() <= 1) { return coll.iterator(); } else { Object array[] = coll.toArray(); Arrays.sort(array, new ThrowableComparator()); return Arrays.asList(array).iterator(); } }
/** * Returns an {@link Iterator} over a {@link Collection} of * Throwable types which iterates over its elements in a * consistent order (maintaining an ordering that is consistent * across different runs makes it easier to compare sets generated * by different implementations of the CFG classes). * * @param coll The collection to iterate over. * * @return An iterator which presents the elements of <code>coll</code> * in order. */ private static Iterator sortedThrowableIterator(Collection coll) { if (coll.size() <= 1) { return coll.iterator(); } else { Object array[] = coll.toArray(); Arrays.sort(array, new ThrowableComparator()); return Arrays.asList(array).iterator(); } }
public int compare(Object o1, Object o2) { RefType t1 = baseType(o1); RefType t2 = baseType(o2); if (t1.equals(t2)) { // There should never be both AnySubType(t) and // t in a ThrowableSet, but if it happens, put // AnySubType(t) first: if (o1 instanceof AnySubType) { if (o2 instanceof AnySubType) { return 0; } else { return -1; } } else if (o2 instanceof AnySubType) { return 1; } else { return 0; } } else { return t1.toString().compareTo(t2.toString()); } }
@Override public int compare(T o1, T o2) { RefType t1 = baseType(o1); RefType t2 = baseType(o2); if (t1.equals(t2)) { // There should never be both AnySubType(t) and // t in a ThrowableSet, but if it happens, put // AnySubType(t) first: if (o1 instanceof AnySubType) { if (o2 instanceof AnySubType) { return 0; } else { return -1; } } else if (o2 instanceof AnySubType) { return 1; } else { return 0; } } else { return t1.toString().compareTo(t2.toString()); } }