List of usage examples for java.util Comparator comparingLong
public static <T> Comparator<T> comparingLong(ToLongFunction<? super T> keyExtractor)
From source file:org.iti.agrimarket.view.FileUploadController.java
public String provideUploadInfo(Model model) { File rootFolder = new File( "C:\\Users\\Amr\\Documents\\GP\\Agri_Market\\agrimarket_gp_iti\\AgriMarket_v2.2"); List<String> fileNames = Arrays.stream(rootFolder.listFiles()).map(f -> f.getName()) .collect(Collectors.toList()); model.addAttribute("files", Arrays.stream(rootFolder.listFiles()).sorted(Comparator.comparingLong(f -> -1 * f.lastModified())) .map(f -> f.getName()).collect(Collectors.toList())); return "uploadForm"; }
From source file:com.walmart.gatling.endpoint.v1.FileUploadController.java
@RequestMapping(method = RequestMethod.GET, value = "/upload") public String provideUploadInfo(Model model) throws IOException { File rootFolder = new File(tempFileDir); if (!rootFolder.exists()) { rootFolder.mkdir();/*from ww w .j a v a 2 s .c o m*/ } rootFolder = new File(tempFileDir); model.addAttribute("files", Arrays.stream(rootFolder.listFiles()).sorted(Comparator.comparingLong(f -> -1 * f.lastModified())) .map(f -> f.getName()).collect(Collectors.toList())); return "uploadForm"; }
From source file:com.galenframework.ide.jobs.TaskResultsStorageCleanupJob.java
private void clearFinishedResults() { List<TaskResult> filteredResults = testResultsStorage.stream().filter((tr) -> tr.getFinishedDate() != null) .sorted(Comparator.comparingLong((tr) -> tr.getFinishedDate().getTime())).collect(toList()); if (filteredResults.size() > keepLastResults) { List<TaskResult> elementsToBeDeleted = filteredResults.subList(0, filteredResults.size() - keepLastResults); testResultsStorage.clear(elementsToBeDeleted::contains); removeExternalReports(elementsToBeDeleted); }//from w w w .j a va 2s.c o m }
From source file:org.ow2.proactive.scheduling.api.graphql.fetchers.JobDataFetcher.java
@Override public Object get(DataFetchingEnvironment environment) { Function<Root<JobData>, Path<? extends Number>> entityId = root -> root.get("id"); BiFunction<CriteriaBuilder, Root<JobData>, List<Predicate[]>> criteria = new JobTaskFilterInputBiFunction( new JobInputConverter(), environment); return createPaginatedConnection(environment, JobData.class, entityId, Comparator.comparingLong(JobData::getId), criteria, new JobCursorMapper()); }
From source file:org.ow2.proactive.scheduling.api.graphql.fetchers.TaskDataFetcher.java
@Override public Object get(DataFetchingEnvironment environment) { Function<Root<TaskData>, Path<? extends Number>> entityId = root -> root.get("id").get("taskId"); BiFunction<CriteriaBuilder, Root<TaskData>, List<Predicate[]>> criteria = new JobTaskFilterInputBiFunction( new TaskInputConverter(), environment); return createPaginatedConnection(environment, TaskData.class, entityId, Comparator.comparingLong(t -> t.getId().getTaskId()), criteria, new TaskCursorMapper()); }
From source file:com.adeptj.runtime.osgi.BundleInstaller.java
Stream<Bundle> install(ClassLoader cl, String bundlesDir) throws IOException { Logger logger = LoggerFactory.getLogger(this.getClass()); Pattern pattern = Pattern.compile("^bundles.*\\.jar$"); return ((JarURLConnection) this.getClass().getResource(bundlesDir).openConnection()).getJarFile().stream() .filter(jarEntry -> pattern.matcher(jarEntry.getName()).matches()) .map(jarEntry -> cl.getResource(jarEntry.getName())).filter(Objects::nonNull).map(url -> { logger.debug("Installing Bundle from location: [{}]", url); Bundle bundle = null;/*from ww w .j av a2 s . c o m*/ try (JarInputStream jis = new JarInputStream(url.openStream(), false)) { if (StringUtils .isEmpty(jis.getManifest().getMainAttributes().getValue(BUNDLE_SYMBOLIC_NAME))) { logger.warn("Artifact [{}] is not a Bundle, skipping install!!", url); } else { bundle = BundleContextHolder.getInstance().getBundleContext() .installBundle(url.toExternalForm()); this.installationCount.incrementAndGet(); } } catch (BundleException | IllegalStateException | SecurityException | IOException ex) { logger.error("Exception while installing Bundle: [{}]. Cause:", url, ex); } return bundle; }).filter(Objects::nonNull).sorted(Comparator.comparingLong(Bundle::getBundleId)); }
From source file:org.ow2.proactive.connector.iaas.cloud.provider.vmware.VMWareProviderVirtualMachineUtil.java
public Optional<Datastore> getDatastoreWithMostSpaceFromHost(HostSystem host) { try {//w w w . j a va 2 s. com return Lists.newArrayList(host.getDatastores()).stream() .filter(datastore -> datastore.getSummary().isAccessible()) .max(Comparator.comparingLong(datastore -> datastore.getSummary().getFreeSpace())); } catch (RemoteException e) { throw new RuntimeException("ERROR when retrieving VMWare datastores from host: " + host.getName(), e); } }
From source file:org.ow2.proactive.connector.iaas.cloud.provider.vmware.VMWareProviderVirtualMachineUtil.java
public Optional<Datastore> getDatastoreWithMostSpaceFromPool(ResourcePool resourcePool) { try {//from ww w . j av a 2s . co m return Lists.newArrayList(resourcePool.getOwner().getDatastores()).stream() .filter(datastore -> datastore.getSummary().isAccessible()) .max(Comparator.comparingLong(datastore -> datastore.getSummary().getFreeSpace())); } catch (RemoteException e) { throw new RuntimeException( "ERROR when retrieving VMWare resource pool's owner from: " + resourcePool.getName(), e); } }
From source file:com.evolveum.midpoint.model.impl.trigger.TriggerScannerTaskHandler.java
private List<TriggerType> getSortedTriggers(List<PrismContainerValue<TriggerType>> triggerCVals) { List<TriggerType> rv = new ArrayList<>(); triggerCVals.forEach(cval -> rv.add(cval.clone().asContainerable())); rv.sort(Comparator.comparingLong(t -> XmlTypeConverter.toMillis(t.getTimestamp()))); return rv;/*from w w w . jav a 2 s . c o m*/ }
From source file:com.netflix.conductor.dao.dynomite.RedisExecutionDAO.java
@Override public Workflow getWorkflow(String workflowId, boolean includeTasks) { Preconditions.checkNotNull(workflowId, "workflowId name cannot be null"); String json = dynoClient.get(nsKey(WORKFLOW, workflowId)); if (json == null) { throw new ApplicationException(Code.NOT_FOUND, "No such workflow found by id: " + workflowId); }/*from ww w . ja v a 2 s.c om*/ Workflow workflow = readValue(json, Workflow.class); if (includeTasks) { List<Task> tasks = getTasksForWorkflow(workflowId); tasks.sort(Comparator.comparingLong(Task::getScheduledTime).thenComparingInt(Task::getSeq)); workflow.setTasks(tasks); } return workflow; }