Class MethodSorter


  • public class MethodSorter
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Comparator<java.lang.reflect.Method> DEFAULT
      DEFAULT sort order
      static java.util.Comparator<java.lang.reflect.Method> NAME_ASCENDING
      Method name ascending lexicographic sort order, with Method.toString() as a tiebreaker
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private MethodSorter()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.reflect.Method[] getDeclaredMethods​(java.lang.Class<?> clazz)
      Gets declared methods of a class in a predictable order, unless @FixMethodOrder(MethodSorters.JVM) is specified.
      private static java.util.Comparator<java.lang.reflect.Method> getSorter​(FixMethodOrder fixMethodOrder)  
      • Methods inherited from class java.lang.Object

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

      • DEFAULT

        public static final java.util.Comparator<java.lang.reflect.Method> DEFAULT
        DEFAULT sort order
      • NAME_ASCENDING

        public static final java.util.Comparator<java.lang.reflect.Method> NAME_ASCENDING
        Method name ascending lexicographic sort order, with Method.toString() as a tiebreaker
    • Constructor Detail

      • MethodSorter

        private MethodSorter()
    • Method Detail

      • getDeclaredMethods

        public static java.lang.reflect.Method[] getDeclaredMethods​(java.lang.Class<?> clazz)
        Gets declared methods of a class in a predictable order, unless @FixMethodOrder(MethodSorters.JVM) is specified. Using the JVM order is unwise since the Java platform does not specify any particular order, and in fact JDK 7 returns a more or less random order; well-written test code would not assume any order, but some does, and a predictable failure is better than a random failure on certain platforms. By default, uses an unspecified but deterministic order.
        Parameters:
        clazz - a class
        Returns:
        same as Class.getDeclaredMethods() but sorted
        See Also:
        JDK (non-)bug #7023180
      • getSorter

        private static java.util.Comparator<java.lang.reflect.Method> getSorter​(FixMethodOrder fixMethodOrder)