public class ReportComparator extends Object implements Comparator<Report>
elements
of a single API analyzer are by definition mutually comparable,
the same doesn't apply for reports. Reports are collected across multiple api analyzers and therefore 2 reports,
coming from 2 different api analyzers can contain elements that are not mutually comparable.
This comparator tries to overcome that and offer a way of ordering all the reports in some predictable order.
Modifier and Type | Class and Description |
---|---|
static class |
ReportComparator.Builder |
static class |
ReportComparator.Strategy
The comparison strategy defines the way the elements of the same type are compared with each other.
|
Modifier | Constructor and Description |
---|---|
protected |
ReportComparator(List<Class<?>> baseTypeOrder,
Map<Class<?>,Comparator<?>> perTypeComparators,
ReportComparator.Strategy comparisonStrategy) |
Modifier and Type | Method and Description |
---|---|
protected <E extends Element<E>> |
compare(E e1,
E e2)
Compares the two elements based on the comparison strategy.
|
int |
compare(Report o1,
Report o2) |
protected int |
defaultCompareIncomparable(Element<?> el1,
Element<?> el2)
This method is called to compare the two elements that are of different base types and no explicit order has been
set for the base types.
|
protected static Class<?> |
getBaseType(Class<?> elementClass)
The elements are always derived from some base type, all subclasses of which must be mutually comparable.
|
protected <E extends Element<E>> |
getComparatorFor(E element) |
protected Element<?> |
getElement(Report report)
Returns the new element or, if the new element is null, the old element of the report.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
protected ReportComparator(List<Class<?>> baseTypeOrder, Map<Class<?>,Comparator<?>> perTypeComparators, ReportComparator.Strategy comparisonStrategy)
public int compare(Report o1, Report o2)
compare
in interface Comparator<Report>
protected int defaultCompareIncomparable(Element<?> el1, Element<?> el2)
protected <E extends Element<E>> Comparator<E> getComparatorFor(E element)
protected <E extends Element<E>> int compare(E e1, E e2)
getComparatorFor(Element)
for direct comparisons of any two elements.E
- the base type of the elementse1
- the first elemente2
- the second elementprotected static Class<?> getBaseType(Class<?> elementClass)
elementClass
- the type of some elementCopyright © 2014-2021 Lukas Krejci. All Rights Reserved.