Example usage for java.util Collections sort

List of usage examples for java.util Collections sort

Introduction

In this page you can find the example usage for java.util Collections sort.

Prototype

@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> void sort(List<T> list, Comparator<? super T> c) 

Source Link

Document

Sorts the specified list according to the order induced by the specified comparator.

Usage

From source file:org.openmrs.module.adminui.page.controller.metadata.locations.ManageLocationAttributeTypesPageController.java

/**
 * @param model/*from w w w.  java2 s  .  c  o m*/
 * @param locationService
 */
public void get(PageModel model, @SpringBean("locationService") LocationService locationService) {
    List<LocationAttributeType> locationAttributeTypes = locationService.getAllLocationAttributeTypes();
    Collections.sort(locationAttributeTypes, new ByRetiredComparator());
    model.addAttribute("locationAttributeTypes", locationAttributeTypes);
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.OpenExecutionYearsProvider.java

@Override
public Object provide(Object source, Object currentValue) {

    final List<ExecutionYear> executionYears = ExecutionYear.readOpenExecutionYears();
    executionYears.add(ExecutionYear.readCurrentExecutionYear());

    Collections.sort(executionYears, new ReverseComparator());

    return executionYears;
}

From source file:org.jtransfo.spring.JTransfoSpring.java

/**
 * Get object finders and type converters from Spring configuration.
 *///from  w w  w  .  ja  v a2 s . c om
@PostConstruct
protected void postConstruct() {
    if (null != typeConverters) {
        getTypeConverters().addAll(typeConverters);
        updateTypeConverters();
    }

    if (null != objectFinders) {
        getObjectFinders().addAll(objectFinders);
        updateObjectFinders();
    }

    if (null != convertInterceptors) {
        Collections.sort(convertInterceptors, new AnnotationAwareOrderComparator());
        getConvertInterceptors().addAll(convertInterceptors);
        updateConvertInterceptors();
    }

}

From source file:io.fineo.drill.exec.store.dynamo.DynamoPlanValidationUtils.java

public static DynamoGroupScanSpec validatePlan(Map<String, Object> dynamo, List<String> columns,
        DynamoReadFilterSpec scan, List<DynamoReadFilterSpec> getOrQuery) throws IOException {
    assertEquals(DynamoGroupScan.NAME, dynamo.get("pop"));
    assertEquals(columns, dynamo.get("columns"));
    assertTrue((Boolean) dynamo.get("filterPushedDown"));
    Map<String, Object> spec = (Map<String, Object>) dynamo.get("spec");
    String specString = MAPPER.writeValueAsString(spec);
    DynamoGroupScanSpec gSpec = MAPPER.readValue(specString, DynamoGroupScanSpec.class);
    if (scan == null) {
        assertNull(gSpec.getScan());//from   w w w .j  a va 2s .  c  o m
        List<DynamoReadFilterSpec> actual = gSpec.getGetOrQuery();
        Collections.sort(actual, (spec1, spec2) -> spec1.toString().compareTo(spec2.toString()));
        assertEquals(getOrQuery, actual);
    } else {
        assertNull(gSpec.getGetOrQuery());
        assertEquals(scan, gSpec.getScan());
    }
    return gSpec;
}

From source file:es.udc.gii.common.eaf.plugin.multiobjective.remainingfront.NSGA2RemainingFrontSelection.java

@Override
public List<NSGA2Individual> selection(EvolutionaryAlgorithm alg, List<NSGA2Individual> newPop,
        List<NSGA2Individual> front, int size) {

    NSGA2Algorithm nsga2 = (NSGA2Algorithm) alg;

    nsga2.getParametersPlugin().calculateParameters(front);

    Collections.sort(front, new CrowdingDistanceComparator<NSGA2Individual>());
    newPop.addAll(front.subList(0, size));

    return newPop;
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.alumni.AlumniSearchDegreeProvider.java

@Override
public Object provide(Object source, Object currentValue) {

    AlumniMailSendToBean bean = (AlumniMailSendToBean) source;
    final List<Degree> degrees = new ArrayList<Degree>(Degree.readAllByDegreeType(bean.getDegreeType()));
    Collections.sort(degrees, new ComparableComparator());
    return degrees;
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.ExecutionYearsProvider.java

@Override
public Object provide(Object source, Object currentValue) {

    final List<ExecutionYear> executionYears = new ArrayList<ExecutionYear>(
            Bennu.getInstance().getExecutionYearsSet());

    Collections.sort(executionYears, new ReverseComparator());

    return executionYears;
}

From source file:org.woofenterprise.dogs.web.controllers.WelcomeController.java

@RequestMapping("/")
public String welcomePage(Model model) {
    List<AppointmentDTO> appointments = new ArrayList<>(facade.findAllAppointmentsForToday());
    Collections.sort(appointments, new Comparator<AppointmentDTO>() {

        @Override/*ww  w . j a  v  a  2  s.  c o m*/
        public int compare(AppointmentDTO o1, AppointmentDTO o2) {
            return o1.getStartTime().compareTo(o2.getStartTime());
        }
    });
    model.addAttribute("appointments", appointments);

    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

    for (GrantedAuthority auth : authentication.getAuthorities()) {

        log.warn("SECURITY PRINCIPLES ROLES: {}", auth.getAuthority());
    }
    return "welcome";
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.AllExecutionPeriodsProvider.java

@Override
public Object provide(Object source, Object currentValue) {
    List<ExecutionSemester> executionSemesters = new ArrayList<ExecutionSemester>(
            Bennu.getInstance().getExecutionPeriodsSet());
    Collections.sort(executionSemesters, new ReverseComparator());
    return executionSemesters;
}

From source file:org.freeeed.search.web.controller.ListUsersController.java

@Override
public ModelAndView execute() {
    log.debug("List users called...");

    if (!loggedSiteVisitor.getUser().hasRight(User.Right.USERS_ADMIN)) {
        try {/*from   w  w w .  j a v a2s .c o m*/
            response.sendRedirect(WebConstants.MAIN_PAGE_REDIRECT);
        } catch (IOException e) {
        }
    }

    List<User> users = userDao.listUsers();
    Collections.sort(users, new Comparator<User>() {

        @Override
        public int compare(User o1, User o2) {
            return o1.getUsername().compareTo(o2.getUsername());
        }

    });

    valueStack.put("users", users);

    return new ModelAndView(WebConstants.LIST_USERS_PAGE);
}