Class ExecutableElementComparator

  • All Implemented Interfaces:
    java.util.Comparator<javax.lang.model.element.ExecutableElement>

    public class ExecutableElementComparator
    extends java.lang.Object
    implements java.util.Comparator<javax.lang.model.element.ExecutableElement>
    The Comparator class for ExecutableElement, the comparison rule :
    1. Comparing to two element names lexicographically. If equals, go to step 2
    2. Comparing to the count of two parameters. If equals, go to step 3
    3. Comparing to the type names of parameters lexicographically

    Example Usage

     class Example {
         void methodA() {}
         void methodB() {}
         void methodB(String param1) {}
         void methodB(String param1, int param2) {}
     }
     

    When comparing methods:

    • methodA vs methodB: the names are compared lexicographically.
    • methodB() vs methodB(String): the number of parameters is compared.
    • methodB(String) vs methodB(String, int): the parameter type names are compared lexicographically.
    Since:
    1.0.0
    Author:
    Mercy
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(javax.lang.model.element.ExecutableElement e1, javax.lang.model.element.ExecutableElement e2)  
      • Methods inherited from class java.lang.Object

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

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Method Detail

      • compare

        public int compare​(javax.lang.model.element.ExecutableElement e1,
                           javax.lang.model.element.ExecutableElement e2)
        Specified by:
        compare in interface java.util.Comparator<javax.lang.model.element.ExecutableElement>