List of usage examples for java.util Collections reverseOrder
@SuppressWarnings("unchecked") public static <T> Comparator<T> reverseOrder(Comparator<T> cmp)
From source file:org.ascent.mmkp.FMRedux.java
public List<FeatureSelection> merge(Feature f) { if (isLeaf(f)) { ArrayList<FeatureSelection> tf = new ArrayList<FeatureSelection>(1); FeatureSelection sol = newSelection(); select(f, sol);//ww w. j av a 2 s. c o m tf.add(sol); return tf; } else if (f.getXorChildren().size() > 0) { List<FeatureSelection> tf = new ArrayList<FeatureSelection>(); for (Feature c : f.getXorChildren()) { tf = sortedMerge(tf, merge(c), Collections.reverseOrder(valueComparator_)); } return tf; } else { List<FeatureSelection> tf = merge(f.getRequiredChildren().get(0)); for (int i = 1; i < f.getRequiredChildren().size(); i++) { List<FeatureSelection> b = merge(f.getRequiredChildren().get(i)); if (b.size() > 1) { if (tf.size() > 1) tf = filteredCrossProduct(tf, b); else tf = b; } } return tf; } }
From source file:net.sourceforge.fenixedu.domain.candidacyProcess.erasmus.ApprovedLearningAgreementDocumentFile.java
protected List<ApprovedLearningAgreementExecutedAction> getSentLearningAgreementActions() { List<ApprovedLearningAgreementExecutedAction> executedActionList = new ArrayList<ApprovedLearningAgreementExecutedAction>(); CollectionUtils.select(getExecutedActionsSet(), new Predicate() { @Override// w ww .j ava 2s.c om public boolean evaluate(Object arg0) { return ((ApprovedLearningAgreementExecutedAction) arg0).isSentLearningAgreementAction(); }; }, executedActionList); Collections.sort(executedActionList, Collections.reverseOrder(ExecutedAction.WHEN_OCCURED_COMPARATOR)); return executedActionList; }
From source file:org.oscarehr.ws.rest.FormsService.java
@GET @Path("/{demographicNo}/all") @Produces("application/json") public FormListTo1 getFormsForHeading(@PathParam("demographicNo") Integer demographicNo, @QueryParam("heading") String heading) { FormListTo1 formListTo1 = new FormListTo1(); if (heading.equals("Completed")) { List<EFormData> completedEforms = formsManager.findByDemographicId(getLoggedInInfo(), demographicNo); Collections.sort(completedEforms, Collections.reverseOrder(EFormData.FORM_DATE_COMPARATOR)); for (EFormData eformData : completedEforms) { int id = eformData.getId(); int formId = eformData.getFormId(); String name = eformData.getFormName(); String subject = eformData.getSubject(); String status = eformData.getSubject(); Date date = eformData.getFormDate(); Boolean showLatestFormOnly = eformData.isShowLatestFormOnly(); formListTo1.add(FormTo1.create(id, demographicNo, formId, FormsManager.EFORM, name, subject, status, date, showLatestFormOnly)); }/* w ww . ja v a 2 s.co m*/ } else { // Only two options right now. Need to change this anyways List<EForm> eforms = formsManager.findByStatus(getLoggedInInfo(), true, null); //This will have to change to accommodate forms too. Collections.sort(eforms, EForm.FORM_NAME_COMPARATOR); for (EForm eform : eforms) { int formId = eform.getId(); String name = eform.getFormName(); String subject = eform.getSubject(); String status = null; Date date = null; Boolean showLatestFormOnly = eform.isShowLatestFormOnly(); formListTo1.add(FormTo1.create(null, demographicNo, formId, FormsManager.EFORM, name, subject, status, date, showLatestFormOnly)); } } return formListTo1; }
From source file: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; }// w ww. j a va 2s. c om // 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; }
From source file:org.ligoj.app.plugin.id.ldap.dao.AbstractContainerLdapRepository.java
@Override public Page<T> findAll(final Set<T> groups, final String criteria, final Pageable pageable, final Map<String, Comparator<T>> customComparators) { // Create the set with the right comparator final List<Sort.Order> orders = IteratorUtils .toList(ObjectUtils.defaultIfNull(pageable.getSort(), new ArrayList<Sort.Order>()).iterator()); orders.add(DEFAULT_ORDER);/*from w ww. j a v a 2 s .com*/ final Sort.Order order = orders.get(0); Comparator<T> comparator = customComparators.get(order.getProperty()); if (order.getDirection() == Direction.DESC) { comparator = Collections.reverseOrder(comparator); } final Set<T> result = new TreeSet<>(comparator); // Filter the groups, filtering by the criteria addFilteredByPattern(groups, criteria, result); // Apply in-memory pagination return inMemoryPagination.newPage(result, pageable); }
From source file:edu.arizona.kra.proposaldevelopment.service.impl.PropDevRoutingStateLookupableHelperServiceImpl.java
/** * Method that generates the search results for the lookup framework. * Called by performLookup()/*from w w w . j av a2 s. c o m*/ * * @see org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl#getSearchResults(java.util.Map) */ @Override public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) { LOG.debug("getSearchResults():" + fieldValues.toString()); checkUserPermissions(); List<ProposalDevelopmentRoutingState> results = new ArrayList<ProposalDevelopmentRoutingState>(); try { results = getPropDevRoutingStateService().findPropDevRoutingState(fieldValues); // sort list DESC by ORDExpedited so 'Yes' rows will be shown first List defaultSortColumns = getDefaultSortColumns(); if (defaultSortColumns.size() > 0) { Collections.sort(results, Collections.reverseOrder(new BeanPropertyComparator(defaultSortColumns, true))); } } catch (Exception e) { e.printStackTrace(); LOG.error(e); } return results; }
From source file:net.sourceforge.fenixedu.domain.candidacyProcess.erasmus.ApprovedLearningAgreementDocumentFile.java
protected List<ApprovedLearningAgreementExecutedAction> getViewedLearningAgreementActions() { List<ApprovedLearningAgreementExecutedAction> executedActionList = new ArrayList<ApprovedLearningAgreementExecutedAction>(); CollectionUtils.select(getExecutedActionsSet(), new Predicate() { @Override// w w w. ja v a 2s . com public boolean evaluate(Object arg0) { return ((ApprovedLearningAgreementExecutedAction) arg0).isViewedLearningAgreementAction(); }; }, executedActionList); Collections.sort(executedActionList, Collections.reverseOrder(ExecutedAction.WHEN_OCCURED_COMPARATOR)); return executedActionList; }
From source file:org.apache.syncope.core.logic.CamelRouteLogic.java
@PreAuthorize("isAuthenticated()") public CamelMetrics metrics() { CamelMetrics metrics = new CamelMetrics(); MetricsRegistryService registryService = context.getContext().hasService(MetricsRegistryService.class); if (registryService == null) { LOG.warn("Camel metrics not available"); } else {//from w w w . j ava2 s .c o m MetricRegistry registry = registryService.getMetricsRegistry(); registry.getTimers().entrySet().stream().map(entry -> { CamelMetrics.MeanRate meanRate = new CamelMetrics.MeanRate(); meanRate.setRouteId(StringUtils.substringBetween(entry.getKey(), ".", ".")); meanRate.setValue(entry.getValue().getMeanRate()); return meanRate; }).forEachOrdered(meanRate -> { metrics.getResponseMeanRates().add(meanRate); }); Collections.sort(metrics.getResponseMeanRates(), (o1, o2) -> Collections .reverseOrder(Comparator.<Double>naturalOrder()).compare(o1.getValue(), o2.getValue())); } return metrics; }
From source file:org.jfrog.hudson.plugins.artifactory.config.ArtifactoryServer.java
public List<String> getSnapshotRepositoryKeysFirst() { List<String> repositoryKeys = getRepositoryKeys(); if (repositoryKeys == null || repositoryKeys.isEmpty()) { return Lists.newArrayList(); }/* w ww .j a va 2 s.c o m*/ Collections.sort(repositoryKeys, Collections.reverseOrder(new RepositoryComparator())); return repositoryKeys; }
From source file:net.sourceforge.fenixedu.domain.residence.StudentsPerformanceReport.java
public static StudentsPerformanceReport readPendingReport(final ExecutionSemester executionSemester) { List<StudentsPerformanceReport> pendingReports = new ArrayList<StudentsPerformanceReport>(); CollectionUtils.select(executionSemester.getStudentsPerformanceReportsSet(), new Predicate() { @Override/*from w ww.ja v a 2 s . co m*/ public boolean evaluate(Object arg0) { return ((StudentsPerformanceReport) arg0).getIsNotDoneAndNotCancelled(); } }, pendingReports); if (pendingReports.isEmpty()) { return null; } Collections.sort(pendingReports, Collections.reverseOrder(COMPARE_BY_REQUEST_DATE)); return pendingReports.iterator().next(); }