Package 

Class CompositeComparator


  • 
    public final class CompositeComparator<T extends Object>
    
                        

    A composite comparator that combines multiple sort comparators. This class allows for sorting based on multiple criteria, where each comparator is applied in sequence.

    This implementation mirrors the Swift Array.sorted(using:) extension behavior:

    • Iterates through each sort comparator in order

    • Returns the first non-equal comparison result

    • If all comparators return equal (0), returns 0 to maintain stable sort order

    • Method Summary

      Modifier and Type Method Description
      Integer compare(T o1, T o2)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CompositeComparator

        CompositeComparator(List<<ERROR CLASS><T>> comparators)
        Parameters:
        comparators - The list of comparators to be combined.