@Override public Stream<Action<?, ?>> stream() { return list.stream(); }
@Override public List<String> getMatchedURIs(final boolean decode) { final List<String> result; if (decode) { result = paths.stream().map(PATH_DECODER).collect(Collectors.toList()); } else { result = paths; } return Collections.unmodifiableList(result); }
@Override public List<String> getMatchedURIs(final boolean decode) { final List<String> result; if (decode) { result = paths.stream().map(PATH_DECODER).collect(Collectors.toList()); } else { result = paths; } return Collections.unmodifiableList(result); }
private ImmutableList<Operation> filterOperations( Predicate<Operation> filter ) { ImmutableList.Builder<Operation> builder = ImmutableList.builder(); operations.stream().filter( filter ).forEach( builder::add ); return builder.build(); }
private int calcGasPricesSize() { return blockGasPrices.stream().map(Array::getLength).mapToInt(Integer::intValue).sum(); }
private String summary() { return summary.stream().collect(Collectors.joining()); }
private int lengthOfCoordinates(LinkedList<String> parts, String last) { return parts.stream().mapToInt(x -> x.length() + 1).sum() + last.length(); }
/** * Returns all named entries in the same order their contents * appear within the archive. * * @param name name of the entry. * @return the Iterable<ZipEntry> corresponding to the * given name * @since 1.9.2 */ public Iterable<ZipEntry> getEntriesInPhysicalOrder(final String name) { if (nameMap.containsKey(name)) { return nameMap.get(name).stream().sorted(OFFSET_COMPARATOR) .collect(Collectors.toList()); } return Collections.emptyList(); }
@Override public QueueStatus queueStatus() { int permits = waiterQueue.stream().map(w -> w.acquirePermits).reduce(0, Integer::sum); return new QueueStatus(waiterQueue.size(), permits); }
<T> Optional<Mapper<T>> findMapper(GenericType<T> type, Config.Key key) { return providers.stream() .map(provider -> provider.apply(type)) .filter(Optional::isPresent) .map(Optional::get) .findFirst() .map(mapper -> castMapper(type, mapper, key)) .map(Mapper::create); }
@GenerateMicroBenchmark public int serialLinkedList() { return linkedList.stream().mapToInt(i -> i).sum(); }
public org.pentaho.di.engine.model.Hop createHop( Operation from, Operation to, String type ) { Preconditions.checkArgument( operations.contains( from ), "!operations.contains(from)" ); Preconditions.checkArgument( operations.contains( to ), "!operations.contains(to)" ); Preconditions.checkArgument( from != to, "from == to" ); org.pentaho.di.engine.model.Hop hop = new org.pentaho.di.engine.model.Hop( from, to, type ); Preconditions.checkState( hops.stream().noneMatch( it -> it.getFrom() == from && it.getTo() == to ), "Hop from %s to %s already exists", from, to ); hops.add( hop ); return hop; }
private Optional<String> prefixPath(@Nullable String tail) { return path.size() == 0 ? tail == null ? Optional.empty() : Optional.of(Route.normalize(tail)) : Optional.of(path.stream() .collect(Collectors.joining("", "", tail == null ? "" : Route.normalize(tail)))); }
@Override public int getNodes() { return IntStream.concat( IntStream.of(graphHopperStorage.getNodes()-1), additionalEdges.stream().flatMapToInt(edge -> IntStream.of(edge.getBaseNode(), edge.getAdjNode()))) .max().getAsInt()+1; }
@Override public void enterMvcRoute(final FuzzyDocParser.MvcRouteContext ctx) { String path = pattern(ctx.annotations); List<String> methods = methods(ctx.annotations); if (methods.isEmpty() && path == null) { // not an mvc method return; } String comment = ctx.doc.getText(); String pattern = prefix.stream().collect(Collectors.joining()) + "/" + Optional.ofNullable(path) .orElse("/"); if (methods.size() == 0) { doc.add(doc("get", normalize(pattern), file, summary(), comment)); } else { methods.stream() .forEach(method -> doc.add(doc(method, normalize(pattern), file, summary(), comment))); } }
@Override public void enterScript(final FuzzyDocParser.ScriptContext ctx) { if (ctx.dot == null && !insideRoute()) { /** * reset prefix when '.' is missing: * * use("prefix") * .get() * * vs * * get("pattern") * * but ignore dot when route(prefix) is present (kotlin) */ popPrefix(); popSummary(); } String comment = Optional.ofNullable(ctx.doc).map(it -> it.getText()).orElse(""); if (ctx.method != null) { String method = ctx.method.getText(); String pattern = prefix.stream().collect(Collectors.joining("")) + "/" + Optional.ofNullable(ctx.pattern) .map(it -> str(it.getText())) .orElse("/"); doc.add(doc(method, normalize(pattern), file, summary(), comment)); } }
varyHeaderValue.set(varyValue); return vhs.stream() .map(variantHolder -> variantHolder.v) .collect(Collectors.toList());
varyHeaderValue.set(varyValue); return vhs.stream() .map(variantHolder -> variantHolder.v) .collect(Collectors.toList());
private void retrieveAndUpdate(final BackupMetadata backupMetadata) { // Retrieve the snapshot metadata and then update the date/status. LinkedList<BackupMetadata> metadataLinkedList = locate(backupMetadata.getSnapshotDate()); if (metadataLinkedList == null) { logger.error( "No previous backupMetaData found. This should not happen. Creating new to ensure app keeps running."); metadataLinkedList = new LinkedList<>(); backupMetadataMap.put(backupMetadata.getSnapshotDate(), metadataLinkedList); } Optional<BackupMetadata> searchedData = metadataLinkedList .stream() .filter(backupMetadata1 -> backupMetadata.equals(backupMetadata1)) .findFirst(); if (!searchedData.isPresent()) { metadataLinkedList.addFirst(backupMetadata); } searchedData.ifPresent( backupMetadata1 -> { backupMetadata1.setCompleted(backupMetadata.getCompleted()); backupMetadata1.setStatus(backupMetadata.getStatus()); backupMetadata1.setCassandraSnapshotSuccess( backupMetadata.isCassandraSnapshotSuccess()); backupMetadata1.setSnapshotLocation(backupMetadata.getSnapshotLocation()); backupMetadata1.setLastValidated(backupMetadata.getLastValidated()); }); }
/** * This seems a little trivial, but we need to guarantee that all Dialects start their sequences on a non-0 value. */ @Test @TestForIssue(jiraKey = "HHH-8814") @RequiresDialectFeature(DialectChecks.SupportsSequences.class) @SkipForDialect( value = SQLServer2012Dialect.class, comment = "SQLServer2012Dialect initializes sequence to minimum value (e.g., Long.MIN_VALUE; Hibernate assumes it is uninitialized." ) public void testStartOfSequence() throws Exception { Session s = openSession(); Transaction tx = s.beginTransaction(); final Person person = new Person(); s.persist( person ); tx.commit(); s.close(); assertTrue( person.getId() > 0 ); assertTrue( sqlStatementInterceptor.getSqlQueries() .stream() .filter( sql -> sql.contains( "product_sequence" ) ) .findFirst() .isPresent() ); }