public static < S > Comparator < S > createComparator ( Class < S > type , String ... orderProperties ) { BeanComparator bc = BeanComparator . forClass ( type ) ; if ( Storable . class . isAssignableFrom ( type ) ) { StorableInfo info = StorableIntrospector . examine ( ( Class ) type ) ; for ( String property : orderProperties ) { bc = orderBy ( bc , OrderedProperty . parse ( info , property ) ) ; } } else { for ( String property : orderProperties ) { Class propertyType ; { String name = property ; if ( name . startsWith ( "+" ) || name . startsWith ( "-" ) ) { name = name . substring ( 1 ) ; } propertyType = propertyType ( type , name ) ; } bc = orderBy ( bc , property , propertyType , Direction . ASCENDING ) ; } } return bc ; }
Convenience method to create a comparator which orders storables by the given order - by properties . The property names may be prefixed with + or - to indicate ascending or descending order . If the prefix is omitted ascending order is assumed .