Example usage for org.apache.commons.collections4.functors TruePredicate INSTANCE

List of usage examples for org.apache.commons.collections4.functors TruePredicate INSTANCE

Introduction

In this page you can find the example usage for org.apache.commons.collections4.functors TruePredicate INSTANCE.

Prototype

Predicate INSTANCE

To view the source code for org.apache.commons.collections4.functors TruePredicate INSTANCE.

Click Source Link

Document

Singleton predicate instance

Usage

From source file:org.jasig.cas.CentralAuthenticationServiceImplWithMockitoTests.java

@Test
public void getTicketsWithNoPredicate() {
    final Collection<Ticket> c = this.cas.getTickets(TruePredicate.INSTANCE);
    assertEquals(c.size(), this.ticketRegMock.getTickets().size());
}

From source file:org.jasig.cas.web.report.StatisticsController.java

/**
 * Handles the request.//from www .ja v a  2  s .  c o  m
 *
 * @param httpServletRequest the http servlet request
 * @param httpServletResponse the http servlet response
 * @return the model and view
 * @throws Exception the exception
 */
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(final HttpServletRequest httpServletRequest,
        final HttpServletResponse httpServletResponse) throws Exception {
    final ModelAndView modelAndView = new ModelAndView(MONITORING_VIEW_STATISTICS);
    modelAndView.addObject("startTime", this.upTimeStartDate);
    final double difference = System.currentTimeMillis() - this.upTimeStartDate.getTime();

    modelAndView
            .addObject("upTime",
                    calculateUptime(difference,
                            new LinkedList<Integer>(Arrays.asList(NUMBER_OF_MILLISECONDS_IN_A_DAY,
                                    NUMBER_OF_MILLISECONDS_IN_AN_HOUR, NUMBER_OF_MILLISECONDS_IN_A_MINUTE,
                                    NUMBER_OF_MILLISECONDS_IN_A_SECOND, 1)),
                            new LinkedList<String>(
                                    Arrays.asList("day", "hour", "minute", "second", "millisecond"))));

    modelAndView.addObject("totalMemory", convertToMegaBytes(Runtime.getRuntime().totalMemory()));
    modelAndView.addObject("maxMemory", convertToMegaBytes(Runtime.getRuntime().maxMemory()));
    modelAndView.addObject("freeMemory", convertToMegaBytes(Runtime.getRuntime().freeMemory()));
    modelAndView.addObject("availableProcessors", Runtime.getRuntime().availableProcessors());
    modelAndView.addObject("serverHostName", httpServletRequest.getServerName());
    modelAndView.addObject("serverIpAddress", httpServletRequest.getLocalAddr());
    modelAndView.addObject("casTicketSuffix", this.casTicketSuffix);

    int unexpiredTgts = 0;
    int unexpiredSts = 0;
    int expiredTgts = 0;
    int expiredSts = 0;

    try {
        final Collection<Ticket> tickets = this.centralAuthenticationService.getTickets(TruePredicate.INSTANCE);

        for (final Ticket ticket : tickets) {
            if (ticket instanceof ServiceTicket) {
                if (ticket.isExpired()) {
                    expiredSts++;
                } else {
                    unexpiredSts++;
                }
            } else {
                if (ticket.isExpired()) {
                    expiredTgts++;
                } else {
                    unexpiredTgts++;
                }
            }
        }
    } catch (final UnsupportedOperationException e) {
        logger.trace("The ticket registry doesn't support this information.");
    }

    modelAndView.addObject("unexpiredTgts", unexpiredTgts);
    modelAndView.addObject("unexpiredSts", unexpiredSts);
    modelAndView.addObject("expiredTgts", expiredTgts);
    modelAndView.addObject("expiredSts", expiredSts);
    modelAndView.addObject("pageTitle", modelAndView.getViewName());

    return modelAndView;
}