List of usage examples for java.lang Long compare
public static int compare(long x, long y)
From source file:technology.tikal.ventas.service.almacen.EntradaService.java
@RequestMapping(value = "/{entradaId}", method = RequestMethod.POST) public void actualizar(@PathVariable final Long pedidoId, @PathVariable final Long entradaId, @Valid @RequestBody final RegistroAlmacenTransient request, final BindingResult result) { if (result.hasErrors()) { throw new NotValidException(result); }//from ww w. j ava 2 s . c om if (Long.compare(request.getId(), entradaId) != 0) { throw new MessageSourceResolvableException( new DefaultMessageSourceResolvable(new String[] { "NoValidRequest.EntradaService.actualizar" }, new String[] { request.getId() + "" }, "El id del path no corresponde al de la info mandada en el body")); } entradaController.actualizar(pedidoId, entradaId, request); }
From source file:org.alex73.osm.monitors.export.ReadChangesets.java
public static void sort(List<Changeset> changesets) { Collections.sort(changesets, new Comparator<Changeset>() { @Override//from w ww.j av a 2 s .c om public int compare(Changeset o1, Changeset o2) { long t1 = o1.getClosedAt().toGregorianCalendar().getTimeInMillis(); long t2 = o2.getClosedAt().toGregorianCalendar().getTimeInMillis(); return Long.compare(t1, t2); } }); }
From source file:natalia.dymnikova.cluster.scheduler.impl.find.optimal.FindOptimalAddressesStrategy.java
@Override public List<Optional<Address>> getNodes(final Tree<List<Address>> versionsList) { final List<Address> addresses = versionsList.stream().flatMap(Collection::stream).distinct() .collect(toList());/*ww w . ja v a 2 s .co m*/ final Map<Address, Snapshot> statesMap = states.getStates(addresses); final ClusterMap clusterMap = new ClusterMap(networkMap, toMap(statesMap)); final List<GroupsRouteWithValues> bestGroups = findBestGroups(versionsList, singletonList(new GroupsRouteWithValues(groupOfAddresses))); final GroupsRouteWithValues bestGroupRoute = bestGroups.stream() .map(group -> new SimpleEntry<>(group, group.getValues().stream().mapToLong(v -> v.orElse(0L)).sum())) .min((o1, o2) -> Long.compare(o1.getValue(), o2.getValue())).map(SimpleEntry::getKey) .orElse(new GroupsRouteWithValues(groupOfAddresses)); final Tree<List<Address>> versions = createVersionsFromGroups(versionsList, bestGroupRoute.getGroups() .stream().filter(Optional::isPresent).map(Optional::get).collect(toList())); return findAllWays(versions, singletonList(new RouteWithValues(clusterMap))).stream() .min((o1, o2) -> comparator.compare( o1.getValues().stream().filter(Optional::isPresent).map(Optional::get).collect(toList()), o2.getValues().stream().filter(Optional::isPresent).map(Optional::get).collect(toList()))) .map(RouteWithValues::getAddresses).orElse(emptyList()); }
From source file:io.horizondb.model.core.fields.LongField.java
/** * {@inheritDoc}/*www . j a v a 2s . co m*/ */ @Override public int compareTo(Field other) { return Long.compare(this.value, other.getLong()); }
From source file:technology.tikal.ventas.service.almacen.SalidaService.java
@RequestMapping(value = "/{registroId}", method = RequestMethod.POST) public void actualizar(@PathVariable final Long pedidoId, @PathVariable final Long registroId, @Valid @RequestBody final RegistroAlmacenTransient request, final BindingResult result) { if (result.hasErrors()) { throw new NotValidException(result); }//w w w . j av a 2 s. c o m if (Long.compare(request.getId(), registroId) != 0) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "NoValidRequest.EntradaDevolucionService.actualizar" }, new String[] { request.getId() + "" }, "El id del path no corresponde al de la info mandada en el body")); } salidaController.actualizar(pedidoId, registroId, request); }
From source file:technology.tikal.ventas.service.catalogo.ProductoDeLineaService.java
@RequestMapping(value = "/{productoId}", method = RequestMethod.POST) public void actualizar(@PathVariable final Long idCatalogo, @PathVariable final Long lineaProductoId, @PathVariable final Long productoId, @Valid @RequestBody final ProductoDeLinea request, final BindingResult result) { if (result.hasErrors()) { throw new NotValidException(result); }/* w ww . j a v a 2 s .c o m*/ if (request.getId() != null && Long.compare(request.getId(), productoId) != 0) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "NoValidRequest.ProductoDeLineaService.actualizar" }, new String[] { request.getId() + "" }, "El id del path no corresponde al de la info mandada en el body")); } productoDeLineaController.actualizar(idCatalogo, lineaProductoId, productoId, request); }
From source file:org.talend.dataprep.api.dataset.row.RowMetadataUtils.java
/** * In case of a date column, return the most used pattern. * * @param column the column to inspect./* w w w.j ava 2 s . c om*/ * @return the most used pattern or null if there's none. */ public static String getMostUsedDatePattern(ColumnMetadata column) { // only filter out non date columns if (Type.get(column.getType()) != Type.DATE) { return null; } final List<PatternFrequency> patternFrequencies = column.getStatistics().getPatternFrequencies(); if (!patternFrequencies.isEmpty()) { patternFrequencies.sort((p1, p2) -> Long.compare(p2.getOccurrences(), p1.getOccurrences())); return patternFrequencies.get(0).getPattern(); } return null; }
From source file:technology.tikal.ventas.service.almacen.SalidaDevolucionService.java
@RequestMapping(value = "/{registroId}", method = RequestMethod.POST) public void actualizar(@PathVariable final Long pedidoId, @PathVariable final Long registroId, @Valid @RequestBody final RegistroAlmacenTransient request, final BindingResult result) { if (result.hasErrors()) { throw new NotValidException(result); }//from w w w .j av a2s . com if (Long.compare(request.getId(), registroId) != 0) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "NoValidRequest.EntradaDevolucionService.actualizar" }, new String[] { request.getId() + "" }, "El id del path no corresponde al de la info mandada en el body")); } salidaDevolucionController.actualizar(pedidoId, registroId, request); }
From source file:technology.tikal.ventas.service.almacen.EntradaDevolucionService.java
@RequestMapping(value = "/{registroId}", method = RequestMethod.POST) public void actualizar(@PathVariable final Long pedidoId, @PathVariable final Long registroId, @Valid @RequestBody final RegistroAlmacenTransient request, final BindingResult result) { if (result.hasErrors()) { throw new NotValidException(result); }//w w w . j a v a2 s.co m if (Long.compare(request.getId(), registroId) != 0) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "NoValidRequest.EntradaDevolucionService.actualizar" }, new String[] { request.getId() + "" }, "El id del path no corresponde al de la info mandada en el body")); } entradaDevolucionController.actualizar(pedidoId, registroId, request); }
From source file:sf.net.experimaestro.scheduler.SchedulerTest.java
/** * Check that these runners started one after the other * * @param runners The runners status check * @param readyness true if a job must finish before the next is ready * @param reorder true if jobs can be run in any order, but one at a time *///from ww w .jav a2 s. c om static private int checkSequence(boolean reorder, boolean readyness, WaitingJob... runners) { int errors = 0; Job[] jobs = new Job[runners.length]; Transaction.run(em -> { for (int i = 0; i < runners.length; i++) { jobs[i] = em.find(Job.class, runners[i].getId()); } }); if (reorder) { Arrays.sort(jobs, (o1, o2) -> Long.compare(o1.getStartTimestamp(), o2.getStartTimestamp())); } for (int i = 0; i < jobs.length - 1; i++) { final long nextTimestamp = readyness ? ((WaitingJob) jobs[i + 1]).status().readyTimestamp : jobs[i + 1].getStartTimestamp(); final long endTimestamp = jobs[i].getEndTimestamp(); if (endTimestamp >= nextTimestamp) { LOGGER.warn("The runners (%s/%x, end=%d) and (%s/%x, start=%d) did not start one after the other", jobs[i], System.identityHashCode(jobs[i]), endTimestamp, jobs[i + 1], System.identityHashCode(jobs[i + 1]), nextTimestamp); errors++; } else LOGGER.debug("The runners (%s/%x) and (%s/%x) started one after the other [%dms]", jobs[i], System.identityHashCode(jobs[i]), jobs[i + 1], System.identityHashCode(jobs[i + 1]), nextTimestamp - endTimestamp); } return errors; }