private Collection < Method > sortControllerMethods ( Set < Method > controllerMethods ) { List < Method > list = new ArrayList <> ( controllerMethods ) ; list . sort ( ( m1 , m2 ) -> { int o1 = Integer . MAX_VALUE ; Order order1 = ClassUtils . getAnnotation ( m1 , Order . class ) ; if ( order1 != null ) { o1 = order1 . value ( ) ; } int o2 = Integer . MAX_VALUE ; Order order2 = ClassUtils . getAnnotation ( m2 , Order . class ) ; if ( order2 != null ) { o2 = order2 . value ( ) ; } if ( o1 == o2 ) { // same or unsorted, compare controller+controllerMethod String s1 = LangUtils . toString ( m1 ) ; String s2 = LangUtils . toString ( m2 ) ; return s1 . compareTo ( s2 ) ; } return ( o1 < o2 ) ? - 1 : 1 ; } ) ; return list ; }
Sort the controller s methods by their preferred order if specified .