notification-portlet-webapp/src/main/java/org/jasig/portlet/notice/util/sort/Sorting.java
private static Comparator<NotificationEntry> chooseConfiguredComparator(HttpServletRequest req) {

        final String strategyName = req.getParameter(SORT_STRATEGY_PARAMETER_NAME);
        if (strategyName == null) {
            // No strategy means "natural" ordering;  we won't be sorting...
            return null;
        }

        // We WILL be sorting;  work out the details...
        try {
            final SortStrategy strategy = SortStrategy.valueOf(strategyName.toUpperCase()); // tolerant of case mismatch
            final String orderName = req.getParameter(SORT_ORDER_PARAMETER_NAME);
            final SortOrder order = StringUtils.isNotBlank(orderName)
                    ? SortOrder.valueOf(orderName.toUpperCase()) // tolerant of case mismatch
                    : SortOrder.valueOf(SORT_ORDER_DEFAULT);

            return order.equals(SortOrder.ASCENDING)
                    ? strategy.getComparator()                             // Default/ascending order
                    : Collections.reverseOrder(strategy.getComparator());  // Descending order
        } catch (IllegalArgumentException e) {
            LOGGER.warn("Unable to sort based on parameters {}='{}' and {}='{}'",
                    SORT_STRATEGY_PARAMETER_NAME,
                    strategyName,
                    SORT_ORDER_PARAMETER_NAME,
                    req.getParameter(SORT_ORDER_PARAMETER_NAME));
        }

        // We didn't succeed in selecting a strategy & order
        return null;

    }
private static Comparator<NotificationEntry> chooseConfiguredComparator(HttpServletRequest req) {

        final String strategyName = req.getParameter(SORT_STRATEGY_PARAMETER_NAME);
        if (strategyName == null) {
            // No strategy means "natural" ordering;  we won't be sorting...
            return null;
        }

        // We WILL be sorting;  work out the details...
        try {
            final SortStrategy strategy = SortStrategy.valueOf(strategyName.toUpperCase()); // tolerant of case mismatch
            final String orderName = req.getParameter(SORT_ORDER_PARAMETER_NAME);
            final SortOrder order = StringUtils.isNotBlank(orderName)
                    ? SortOrder.valueOf(orderName.toUpperCase()) // tolerant of case mismatch
                    : SortOrder.valueOf(SORT_ORDER_DEFAULT);

            return order.equals(SortOrder.ASCENDING)
                    ? strategy.getComparator()                             // Default/ascending order
                    : Collections.reverseOrder(strategy.getComparator());  // Descending order
        } catch (IllegalArgumentException e) {
            LOGGER.warn("Unable to sort based on parameters {}='{}' and {}='{}'",
                    SORT_STRATEGY_PARAMETER_NAME,
                    strategyName,
                    SORT_ORDER_PARAMETER_NAME,
                    req.getParameter(SORT_ORDER_PARAMETER_NAME));
        }

        // We didn't succeed in selecting a strategy & order
        return null;

    }
private static Comparator < NotificationEntry > chooseConfiguredComparator ( HttpServletRequest req ) { final String strategyName = req . getParameter ( SORT_STRATEGY_PARAMETER_NAME ) ; if ( strategyName == null ) { // No strategy means "natural" ordering;  we won't be sorting... return null ; } // We WILL be sorting;  work out the details... try { final SortStrategy strategy = SortStrategy . valueOf ( strategyName . toUpperCase ( ) ) ; // tolerant of case mismatch final String orderName = req . getParameter ( SORT_ORDER_PARAMETER_NAME ) ; final SortOrder order = StringUtils . isNotBlank ( orderName ) ? SortOrder . valueOf ( orderName . toUpperCase ( ) ) // tolerant of case mismatch : SortOrder . valueOf ( SORT_ORDER_DEFAULT ) ; return order . equals ( SortOrder . ASCENDING ) ? strategy . getComparator ( ) // Default/ascending order : Collections . reverseOrder ( strategy . getComparator ( ) ) ; // Descending order } catch ( IllegalArgumentException e ) { LOGGER . warn ( "Unable to sort based on parameters {}='{}' and {}='{}'" , SORT_STRATEGY_PARAMETER_NAME , strategyName , SORT_ORDER_PARAMETER_NAME , req . getParameter ( SORT_ORDER_PARAMETER_NAME ) ) ; } // We didn't succeed in selecting a strategy & order return null ; }
/*
Implementation
/ * Implementation