List of usage examples for java.util List sort
@SuppressWarnings({ "unchecked", "rawtypes" }) default void sort(Comparator<? super E> c)
From source file:org.talend.dataprep.transformation.actions.date.ChangeDatePattern.java
/** * Return the count of the most used pattern. * * @param column the column to work on./*ww w.j a v a2s.c om*/ * @return the count of the most used pattern. */ private long getMostUsedPatternCount(ColumnMetadata column) { final List<PatternFrequency> patternFrequencies = column.getStatistics().getPatternFrequencies(); if (patternFrequencies.isEmpty()) { return 1; } patternFrequencies.sort((p1, p2) -> Long.compare(p2.getOccurrences(), p1.getOccurrences())); return patternFrequencies.get(0).getOccurrences(); }
From source file:org.sonar.server.qualityprofile.QProfileBackuperImpl.java
@Override public void backup(DbSession dbSession, QualityProfileDto profileDto, Writer writer) { List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKey()); activeRules.sort(BackupActiveRuleComparator.INSTANCE); writeXml(dbSession, writer, profileDto, activeRules.iterator()); }
From source file:com.netflix.spinnaker.halyard.deploy.deployment.v1.DistributedDeployer.java
private <T extends Account> void reapOrcaServerGroups(AccountDeploymentDetails<T> details, SpinnakerRuntimeSettings runtimeSettings, DistributedService<Orca, T> orcaService) { Orca orca = orcaService.connectToPrimaryService(details, runtimeSettings); Map<String, ActiveExecutions> executions = orca.getActiveExecutions(); ServiceSettings orcaSettings = runtimeSettings.getServiceSettings(orcaService.getService()); RunningServiceDetails orcaDetails = orcaService.getRunningServiceDetails(details, runtimeSettings); Map<String, Integer> executionsByInstance = new HashMap<>(); executions.forEach((s, e) -> {/*from w w w.j a va 2s . co m*/ String instanceId = s.split("@")[1]; executionsByInstance.put(instanceId, e.getCount()); }); Map<Integer, Integer> executionsByServerGroupVersion = new HashMap<>(); orcaDetails.getInstances().forEach((s, is) -> { int count = is.stream().reduce(0, (c, i) -> c + executionsByInstance.getOrDefault(i.getId(), 0), (a, b) -> a + b); executionsByServerGroupVersion.put(s, count); }); // Omit the last deployed orcas from being deleted, since they are kept around for rollbacks. List<Integer> allOrcas = new ArrayList<>(executionsByServerGroupVersion.keySet()); allOrcas.sort(Integer::compareTo); int orcaCount = allOrcas.size(); if (orcaCount <= MAX_REMAINING_SERVER_GROUPS) { return; } allOrcas = allOrcas.subList(0, orcaCount - MAX_REMAINING_SERVER_GROUPS); for (Integer orcaVersion : allOrcas) { // TODO(lwander) consult clouddriver to ensure this orca isn't enabled if (executionsByServerGroupVersion.get(orcaVersion) == 0) { DaemonTaskHandler.message("Reaping old orca instance " + orcaVersion); orcaService.deleteVersion(details, orcaSettings, orcaVersion); } } }
From source file:ch.digitalfondue.jfiveparse.TreeConstructionTest.java
@Parameters(name = "{0}:{index}:{2}") public static List<Object[]> data() throws IOException { List<Object[]> data = new ArrayList<>(); try (DirectoryStream<Path> ds = Files .newDirectoryStream(Paths.get("src/test/resources/html5lib-tests/tree-construction"), "*.dat")) { for (Path p : ds) { String file = new String(Files.readAllBytes(p), StandardCharsets.UTF_8); String[] testsAsString = file.split("\n\n#data\n"); for (String t : testsAsString) { TreeConstruction treeTest = parse(t); if (treeTest.scriptingFlag == null) { data.add(new Object[] { p.getFileName().toString(), treeTest, false }); data.add(new Object[] { p.getFileName().toString(), treeTest, true }); } else if (treeTest.scriptingFlag) { data.add(new Object[] { p.getFileName().toString(), treeTest, true }); } else { data.add(new Object[] { p.getFileName().toString(), treeTest, false }); }// w ww . j av a 2 s . c om } } } data.sort(new Comparator<Object[]>() { public int compare(Object[] o1, Object[] o2) { return new CompareToBuilder().append((String) o1[0], (String) o2[0]) .append((boolean) o1[2], (boolean) o2[2]).toComparison(); } }); return data; }
From source file:de.micromata.mgc.javafx.launcher.gui.AbstractConfigDialog.java
@Override public void initializeWithModel() { configModel = model;//from w w w .j av a 2 s .c o m addCss(); ControllerService cv = ControllerService.get(); List<TabConfig> tabs = getConfigurationTabs(); tabs.sort((e1, e2) -> Integer.compare(e1.prio, e2.prio)); for (TabConfig tabc : tabs) { Pair<Pane, ? extends AbstractConfigTabController<?>> wc = cv .loadControllerControl(tabc.tabControlerClass, Pane.class, this); createTab(tabc.configModel, wc); } AnchorPane.setTopAnchor(mainPane, 5.0); AnchorPane.setRightAnchor(mainPane, 5.0); AnchorPane.setLeftAnchor(mainPane, 5.0); AnchorPane.setBottomAnchor(mainPane, 50.0); AnchorPane.setTopAnchor(configurationTabs, 5.0); AnchorPane.setRightAnchor(configurationTabs, 5.0); AnchorPane.setLeftAnchor(configurationTabs, 5.0); AnchorPane.setBottomAnchor(configurationTabs, 5.0); // AnchorPane.setTopAnchor(buttonHBox, 5.0); AnchorPane.setRightAnchor(buttonPane, 5.0); AnchorPane.setLeftAnchor(buttonPane, 5.0); AnchorPane.setBottomAnchor(buttonPane, 5.0); }
From source file:com.epam.dlab.billing.azure.AzureBillableResourcesService.java
/** * Collects billable resources//w w w . ja v a2 s. c o m * * @return set of all billable resources that were created in scope by DLab from its installation to current time */ public Set<AzureDlabBillableResource> getBillableResources() { Set<AzureDlabBillableResource> billableResources = new HashSet<>(); billableResources.addAll(getSsn()); billableResources.addAll(getDataLake()); billableResources.addAll(getEdgeAndStorageAccount()); billableResources.addAll(getNotebooksAndClusters()); List<AzureDlabBillableResource> list = new ArrayList<>(billableResources); list.sort(Comparator.comparing(AzureDlabBillableResource::getId)); try { log.debug("Billable resources is \n {}", objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(list)); } catch (JsonProcessingException e) { log.debug("Error during pretty printing. Show simple list", e); log.debug("Billable resources is {}", list); } return billableResources; }
From source file:hydrograph.ui.graph.execution.tracking.replay.ViewExecutionHistoryDataDialog.java
/** * The Function will set Table column values * @param tableViewer//from w ww . j ava2 s. co m * @param jobDetails */ private void setTableColumnValues(TableViewer tableViewer, List<Job> jobDetails) { jobDetails.sort((job1, job2) -> job2.getUniqueJobId().compareTo(job1.getUniqueJobId())); jobDetails.forEach(job -> { String timeStamp = getTimeStamp(job.getUniqueJobId()); TableItem items = new TableItem(table, SWT.None); items.setText(0, job.getUniqueJobId()); items.setText(1, timeStamp); String mode = getJobExecutionMode(job.isRemoteMode()); items.setText(2, mode); items.setText(3, job.getJobStatus()); }); }
From source file:org.fao.geonet.MergeUsersByUsernameDatabaseMigration.java
private void mergeUsers(ApplicationContext applicationContext, String duplicatedUsername) throws Exception { UserRepository userRepository = applicationContext.getBean(UserRepository.class); List<User> duplicatedUserList = userRepository.findByUsernameIgnoreCase(duplicatedUsername); duplicatedUserList.sort(Comparator.comparing(User::getProfile)); User greatestProfileUser = duplicatedUserList.get(0); User userToKeep = userRepository.findOne(greatestProfileUser.getId()); Set<String> emails = new HashSet<>(); Set<Address> addresses = new HashSet<>(); mergeGroups(applicationContext, duplicatedUserList, userToKeep); transferMetadata(applicationContext, duplicatedUserList, userToKeep); transferSavedSelections(applicationContext, duplicatedUserList, userToKeep); User tempUser = new User(); for (int i = duplicatedUserList.size() - 1; i >= 0; i--) { // i = 1 is intended User duplicatedUser = duplicatedUserList.get(i); addresses.addAll(duplicatedUser.getAddresses()); mergeUser(tempUser, duplicatedUser); emails.addAll(duplicatedUser.getEmailAddresses()); }// w w w. j a v a 2 s . co m mergeUser(userToKeep, tempUser); duplicatedUserList.remove(greatestProfileUser); userRepository.delete(duplicatedUserList); userToKeep.setUsername(userToKeep.getUsername().toLowerCase()); userRepository.save(userToKeep); }
From source file:org.languagetool.dev.RuleOverview.java
private List<Language> getSortedLanguages() { final List<Language> sortedLanguages = new ArrayList<>(Languages.get()); sortedLanguages.sort(comparing(Language::getName)); return sortedLanguages; }
From source file:org.pgptool.gui.ui.encrypttext.EncryptTextPm.java
private void initModelProperties() { List<Key> allKeys = keyRingService.readKeys(); allKeys.sort(new ComparatorKeyByNameImpl()); availabileRecipients = new ModelListProperty<Key>(this, new ValueAdapterReadonlyImpl<List<Key>>(allKeys), "availabileRecipients"); selectedRecipients = new ModelMultSelInListProperty<Key>(this, new ValueAdapterHolderImpl<List<Key>>(new ArrayList<Key>()), "projects", availabileRecipients); selectedRecipients.getModelMultSelInListPropertyAccessor() .addListExEventListener(onRecipientsSelectionChanged); onRecipientsSelectionChanged.onListChanged(); sourceText = new ModelProperty<>(this, new ValueAdapterHolderImpl<String>(""), "textToEncrypt"); sourceText.getModelPropertyAccessor().addPropertyChangeListener(onSourceTextChanged); actionDoOperation.setEnabled(false); targetText = new ModelProperty<>(this, new ValueAdapterHolderImpl<String>(""), "encryptedText"); targetText.getModelPropertyAccessor().addPropertyChangeListener(onTargetTextChanged); actionCopyTargetToClipboard.setEnabled(false); }