Package org.zkoss.zul

Class ArrayComparator<E>

  • All Implemented Interfaces:, java.util.Comparator<E>

    public class ArrayComparator<E>
    extends java.lang.Object
    implements java.util.Comparator<E>,
    Compares the specified element of the array. It assumes the data passed to compare(E, E) is an array, and it compares the n-th element, where n is passed in the constructor, ArrayComparator(int, boolean) (the index parameter). It also assumes the element must implement Comparable.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructor Description
      ArrayComparator​(int index, boolean ascending)
      The constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(E o1, E o2)  
      boolean equals​(java.lang.Object o)  
      int getIndex()
      Returns the index of the element.
      int hashCode()  
      boolean isAscending()
      Returns whether the sorting is ascending.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • ArrayComparator

        public ArrayComparator​(int index,
                               boolean ascending)
        The constructor.
        index - which index of an array to compare
        ascending - whether to sort as ascending (or descending).
    • Method Detail

      • compare

        public int compare​(E o1,
                           E o2)
        Specified by:
        compare in interface java.util.Comparator<E>
      • getIndex

        public int getIndex()
        Returns the index of the element.
      • isAscending

        public boolean isAscending()
        Returns whether the sorting is ascending.
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Comparator<E>
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        hashCode in class java.lang.Object