Code example for Comparator

Methods: compare

0
    public final int compare(T o1, T o2) {
        final C c1 = this.getComparable(o1);
        final C c2 = this.getComparable(o2);
         
        if (this.comparator != null) {
            return this.comparator.compare(c1, c2);
        } 
         
        if (c1 == null && c1 == c2) {
            return 0; 
        } 
         
        return c1.compareTo(c2);
    } 
     
    protected abstract C getComparable(T o);
}