Refine search
@Override public LongStream events() throws IOException { DataInputStream input = new DataInputStream(new BufferedInputStream(readFiles())); LongStream stream = StreamSupport.longStream(Spliterators.spliteratorUnknownSize( new TraceIterator(input), Spliterator.ORDERED), /* parallel */ false); return stream.onClose(() -> Closeables.closeQuietly(input)); }
public static <T> List<T> reverse_customStream(ArrayDeque<T> list) { if (list == null) { throw new IllegalArgumentException("list can't be null"); } return StreamSupport.stream(Spliterators.spliteratorUnknownSize(list.descendingIterator(), Spliterator.ORDERED), false).collect(toList()); }
private void authenticate(HttpServletRequest request, HttpServletResponse response) { Optional<String> urlToAuthenticate = Optional.ofNullable(request.getHeader("X-Original-URI")); Optional<String> path = urlToAuthenticate.flatMap(s -> { try { return Optional.of(new URI(s).getPath()); } catch (URISyntaxException e) { LOGGER.error("Failed to parse url [" + s + "]", e); Optional<Matcher> matcher = path.flatMap(p -> getRegexStream().map(regex -> regex.matcher(p)).filter(Matcher::find).findFirst()); Optional<String> host = matcher.map(res -> res.group("host")); Integer httpCode = StreamSupport.stream(getRegistry().getAllProxies().spliterator(), false) .filter(proxy -> proxy instanceof DockerSeleniumRemoteProxy) .map(proxy -> ((DockerSeleniumRemoteProxy)proxy).getRegistration())
public AbstractListAssert<?, List<? extends Tuple>, Tuple, ObjectAssert<Tuple>> extracting(@SuppressWarnings("unchecked") Function<ELEMENT, ?>... extractors) { Function<ELEMENT, Tuple> tupleExtractor = objectToExtractValueFrom -> new Tuple(Stream.of(extractors) .map(extractor -> extractor.apply(objectToExtractValueFrom)) .toArray()); List<Tuple> tuples = stream(actual.spliterator(), false).map(tupleExtractor) .collect(toList()); return newListAssertInstanceForMethodsChangingElementType(tuples);
public static void testAllServicesAreAvailable() { Set<String> osgiAvailableClasses = stream(spliterator(OsgiServiceLoader.load(ServiceFactory.class).iterator(), Long.MAX_VALUE, 0), false) .map(f -> f.getClass().getName()) .collect(toSet()); Set<String> jdkAvailableClasses = of(EhcacheActivator.getCoreBundle().getBundles()) .map(b -> b.adapt(BundleWiring.class).getClassLoader()) .flatMap(cl -> stream(spliterator(ServiceLoader.load(ServiceFactory.class, cl).iterator(), Long.MAX_VALUE, 0), false) .map(f -> f.getClass().getName())) .collect(toSet()); assertThat(osgiAvailableClasses, hasItems(jdkAvailableClasses.toArray(new String[0]))); }
public Optional<List<String>> readStringArrayIfPresent(String property) { if (jsonObject.has(property)) { try { Spliterator<JsonElement> iterator = jsonObject.getAsJsonArray(property).spliterator(); return Optional.of( StreamSupport.stream(iterator, false) .map(JsonElement::getAsString) .collect(Collectors.toList())); } catch (Exception e) { throw haltBecausePropertyIsNotAJsonStringArray(property, jsonObject); } } return Optional.empty(); }
LOG.error("Couldn't get mapping for index <{}>: {}", indexName, ExceptionUtils.getRootCauseMessage(e)); return Optional.empty(); return Optional.empty(); final Spliterator<Map.Entry<String, JsonNode>> fieldSpliterator = Spliterators.spliteratorUnknownSize(properties.fields(), Spliterator.IMMUTABLE); final Set<FieldTypeDTO> fieldsMap = StreamSupport.stream(fieldSpliterator, false) .map(field -> Maps.immutableEntry(field.getKey(), field.getValue().path("type").asText())) .filter(field -> !field.getValue().isEmpty()) .map(field -> FieldTypeDTO.create(field.getKey(), field.getValue())) .collect(Collectors.toSet()); return Optional.of(IndexFieldTypesDTO.create(indexSetId, indexName, fieldsMap));
@Nullable private static Tree suppressibleNode(TreePath path) { return StreamSupport.stream(path.spliterator(), false) .filter( tree -> tree instanceof MethodTree || (tree instanceof ClassTree && ((ClassTree) tree).getSimpleName().length() != 0) || tree instanceof VariableTree) .findFirst() .orElse(null); }
private List<String> getBranches(final org.uberfire.java.nio.file.Path rootPath, final Path projectPath) { final FileSystem fs = rootPath.getFileSystem(); final String exampleRootPath = pathUtil.stripRepoNameAndSpace(pathUtil.stripProtocolAndBranch(projectPath.toURI())); return StreamSupport.stream(fs.getRootDirectories().spliterator(), false) .filter(root -> exists(root.resolve(exampleRootPath))) .map(pathUtil::convert) .map(root -> pathUtil.extractBranch(root.toURI())) .flatMap(oBranch -> oBranch.map(Stream::of).orElse(Stream.empty())) .collect(toList()); }
@Override public List<T> doShrink(SourceOfRandomness random, T larger) { if (larger.equals(leastMagnitude())) return emptyList(); List<T> results = stream( halvingIntegral( widen().apply(larger), widen().apply(leastMagnitude()) ).spliterator(), false) .limit(15) .map(narrow()) .filter(inRange()) .distinct() .collect(toList()); Collections.reverse(results); results.add(leastMagnitude()); if (negative(larger)) results.add(negate(larger)); return results; }
private static String findNamespace(Path file, Set<Path> roots) { Path root = roots.stream() .filter(file::startsWith) .findFirst() .orElseThrow(() -> new IllegalStateException("No source root found for " + file.toString())); String fileName = file.getFileName().toString(); Path relPath = root.relativize(file).resolveSibling(fileName.substring(0, fileName.lastIndexOf('.'))); return StreamSupport.stream(relPath.spliterator(), false) .map(Path::toString) .map(Namespaces::demunge) .collect(Collectors.joining(".")); }
@Override public void start(BundleContext context) throws Exception { BundleContext currentContext = CORE_BUNDLE.getAndUpdate(current -> current == null ? context : current); if (currentContext == null) { String greeting = "Detected OSGi Environment (core is in bundle: " + context.getBundle() + ")"; if ("false".equalsIgnoreCase(context.getProperty(OSGI_LOADING))) { SafeOsgi.disableOSGiServiceLoading(); LOGGER.info(greeting + ": OSGi Based Service Loading Disabled Via System/Framework Property - Extensions Outside This Bundle Will Not Be Detected"); LOGGER.debug("JDK Service Loading Sees:\n\t" + stream(spliterator(ClassLoading.servicesOfType(ServiceFactory.class).iterator(), Long.MAX_VALUE, 0), false) .map(sf -> sf.getServiceType().getName()).collect(joining("\n\t"))); } else { SafeOsgi.enableOSGiServiceLoading(); LOGGER.info(greeting + ": Using OSGi Based Service Loading"); } } else { throw new IllegalStateException("Multiple bundle instances running against the same core classes: existing bundle: " + currentContext.getBundle() + " new bundle: " + context.getBundle()); } }
private Collection<Mutation> getMutationsForMultipleObjects(Iterable it, Function<Object, Collection<Mutation>> individualEntityMutationFunc) { return (Collection<Mutation>) StreamSupport.stream(it.spliterator(), false) .flatMap((x) -> individualEntityMutationFunc.apply(x).stream()) .collect(Collectors.toList()); }
return Optional.empty(); StreamSupport.stream(where.spliterator(), false) .filter(tree -> supportedWhitelistLocationKinds.contains(tree.getKind())) .filter(Predicates.not(SuggestedFixes::isAnonymousClassTree)) .findFirst(); return whitelistLocation.map( location -> builder.prefixWith(location, "@" + annotationName + " ").build());