List of usage examples for java.util Arrays stream
public static DoubleStream stream(double[] array)
From source file:com.github.ukase.service.BulkRenderer.java
private void checkSubDirectories(File subDir) { if (subDir.isDirectory() && subDir.getName().length() == SUB_DIR_NAME_LENGTH) { File[] pdfs = subDir.listFiles(); if (pdfs == null) { return; }/*from www .j a va2s . c o m*/ Arrays.stream(pdfs).forEach(this::registerPdf); } }
From source file:com.ejisto.core.classloading.ClassTransformerImpl.java
private void removeFinalModifierFromFields(CtField[] fields) { Arrays.stream(fields).filter(field -> Modifier.isFinal(field.getModifiers())) .forEach(field -> field.setModifiers(Modifier.clear(field.getModifiers(), Modifier.FINAL))); }
From source file:org.elasticsearch.client.CustomRestHighLevelClientTests.java
/** * The {@link RestHighLevelClient} must declare the following execution methods using the <code>protected</code> modifier * so that they can be used by subclasses to implement custom logic. *///from w w w . j a v a 2 s .c om @SuppressForbidden(reason = "We're forced to uses Class#getDeclaredMethods() here because this test checks protected methods") public void testMethodsVisibility() throws ClassNotFoundException { final String[] methodNames = new String[] { "parseEntity", "parseResponseException", "performRequest", "performRequestAndParseEntity", "performRequestAsync", "performRequestAsyncAndParseEntity" }; final Set<String> protectedMethods = Arrays.stream(RestHighLevelClient.class.getDeclaredMethods()) .filter(method -> Modifier.isProtected(method.getModifiers())).map(Method::getName) .collect(Collectors.toCollection(TreeSet::new)); assertThat(protectedMethods, contains(methodNames)); }
From source file:org.rapidpm.microservice.optionals.service.ServiceWrapper.java
private static Optional<Annotation> getAnnotation() { return Arrays.stream(BasicAdministration.class.getAnnotations()) .filter(a -> a.annotationType().equals(Path.class)).findFirst(); }
From source file:com.fns.grivet.service.EntityServiceTest.java
@AfterEach public void tearDown() { String[] types = { "TestType", "TestType2" }; Arrays.stream(types).forEach(type -> classRegistryService.deregister(type)); }
From source file:com.intellij.plugins.haxe.model.HaxeFileModel.java
public List<HaxeImportModel> getImportModels() { return Arrays.stream(file.getChildren()).filter(element -> element instanceof HaxeImportStatement) .map(element -> ((HaxeImportStatement) element).getModel()).collect(Collectors.toList()); }
From source file:org.leandreck.endpoints.processor.model.MethodNodeFactory.java
private static boolean defineIgnored(final ExecutableElement methodElement, final RequestMapping requestMapping) { boolean hasIgnoreAnnotation = methodElement.getAnnotation(TypeScriptIgnore.class) != null; boolean hasRequestMappingAnnotation = requestMapping != null; boolean producesJson = hasRequestMappingAnnotation && Arrays.stream(requestMapping.produces()) .map(value -> value.startsWith(MediaType.APPLICATION_JSON_VALUE)).reduce(false, (a, b) -> a || b); boolean isPublic = methodElement.getModifiers().contains(Modifier.PUBLIC); return hasIgnoreAnnotation || !isPublic || !hasRequestMappingAnnotation || !producesJson; }
From source file:org.xwiki.contrib.repository.pypi.internal.dto.wheelMetadata.RequiredDistributions.java
private static VersionConstraint getVersionOfDependency(String versionPart) throws ResolveException { String[] versionsIndications = versionPart.substring(1, versionPart.length() - 1).split(","); return Arrays.stream(versionsIndications).map(versionInd -> { try {/*from w ww .ja v a2 s. c om*/ if (versionInd.contains(">=")) { String version = versionInd.replace(">=", ""); return new DefaultVersionConstraint( Collections.singleton(new DefaultVersionRangeCollection("[" + version + ",)")), new DefaultVersion(version)); } else if (versionInd.contains("==")) { String version = versionInd.replace("==", ""); return new DefaultVersionConstraint( Collections.singleton(new DefaultVersionRangeCollection("(," + version + "]")), new DefaultVersion(version)); } else if (versionInd.contains("<=")) { String version = versionInd.replace("<=", ""); return new DefaultVersionConstraint( Collections.singleton(new DefaultVersionRangeCollection("(," + version + "]")), new DefaultVersion(version)); } return null; } catch (InvalidVersionRangeException e) { //shouldNeverHappen return null; } }).filter(Objects::nonNull).findFirst().orElse(null); }
From source file:org.obiba.mica.core.service.SchemaFormContentFileService.java
private void cleanFileJsonArrays(JSONArray... arrays) { if (arrays != null) { Arrays.stream(arrays).forEach(s -> s.forEach(a -> { if (a instanceof LinkedHashMap) { LinkedHashMap<String, String> jsonMap = (LinkedHashMap<String, String>) a; jsonMap.keySet().stream().filter(k -> k.contains("$")).collect(Collectors.toList()) .forEach(jsonMap::remove); }//from w w w.j a v a2s . c om })); } }
From source file:com.act.reachables.LoadAct.java
private static void addToNw(Reaction rxn) { /**/*from w ww . j a v a2 s . c o m*/ * This class takes in a reaction and adds it to ActData. * * Special handling is afforded to abstract reactions and reactions w/ only cofactors as substrates. */ Long rxnid = (long) rxn.getUUID(); // Filter out abstract substrates. These reactions are invalid Long[] inputChemicalsArray = ArrayUtils.addAll(rxn.getSubstrates(), rxn.getSubstrateCofactors()); // Some reactions have coenzymes, so don't forget about those. inputChemicalsArray = ArrayUtils.addAll(inputChemicalsArray, rxn.getCoenzymes()); if (Arrays.stream(inputChemicalsArray).anyMatch(x -> ActData.instance().metaCycBigMolsOrRgrp.contains(x))) { logProgress(String.format("Skipping reaction %d as it contains an abstract substrate.", rxnid)); return; } // Remove cofactors from the needed substrates. List<Long> inputChemicals = Arrays.asList(inputChemicalsArray).stream() .filter(c -> !ActData.instance().cofactors.contains(c)).collect(Collectors.toList()); Long[] outputChemicalsArray = ArrayUtils.addAll(rxn.getProducts(), rxn.getProductCofactors()); // Output chemicals, only real ones. Also remove all of the cofactors as we don't care if those are produced. List<Long> outputChemicals = Arrays.asList(outputChemicalsArray).stream() .filter(p -> !ActData.instance().metaCycBigMolsOrRgrp.contains(p) && !ActData.instance().cofactors.contains(p)) .collect(Collectors.toList()); // Don't bother if we don't get any new chemicals from this. if (outputChemicals.isEmpty()) { logProgress(String.format("Skipping reaction %d as it has no non-abstract products.", rxnid)); return; } if (inputChemicals.isEmpty()) { logProgress(String.format( "Undoing filtering on reaction %d substrates as it has only cofactor substrates.", rxnid)); // These will be substrate only inputChemicals = Arrays.asList(inputChemicalsArray); } // Load all the nodeMapping. inputChemicals.stream().distinct().forEach(s -> { Node sub = Node.get(s, true); ActData.instance().chemsInAct.put(s, sub); ActData.instance().Act.addNode(sub, s); outputChemicals.stream().distinct().forEach(p -> { Node prd = Node.get(p, true); ActData.instance().Act.addNode(prd, p); ActData.instance().chemsInAct.put(p, prd); Edge r = Edge.get(sub, prd, true); ActData.instance().Act.addEdge(r); }); }); Set<Long> inputSet = new HashSet<>(inputChemicals); Set<Long> outputSet = new HashSet<>(outputChemicals); /* --------------- Update ActData ------------------ */ ActData.instance().rxnSubstrates.put(rxnid, inputSet); ActData.instance().rxnProducts.put(rxnid, outputSet); inputSet.stream().forEach(ActData.instance().chemsReferencedInRxns::add); outputSet.stream().forEach(ActData.instance().chemsReferencedInRxns::add); inputSet.stream().forEach(s -> { Set<Long> pSet = ActData.instance().rxnsThatConsumeChem.getOrDefault(s, new HashSet<>()); pSet.add(rxnid); ActData.instance().rxnsThatConsumeChem.put(s, pSet); }); outputSet.stream().forEach(p -> { Set<Long> pSet = ActData.instance().rxnsThatProduceChem.getOrDefault(p, new HashSet<>()); pSet.add(rxnid); ActData.instance().rxnsThatProduceChem.put(p, pSet); }); // add to internal copy of network ActData.instance().rxnHasSeq.put(rxnid, rxn.hasProteinSeq()); /* -------- Reaction Classes ------- */ Pair<Set<Long>, Set<Long>> rxnClass = Pair.of(inputSet, outputSet); if (!ActData.instance().rxnClasses.contains(rxnClass)) { // the first reaction that shows up in this class, get to // represent the entire class. So we install it in the // datasets mirroring the non-class structures... ActData.instance().rxnClassesSubstrates.put(rxnid, inputSet); ActData.instance().rxnClassesProducts.put(rxnid, outputSet); ActData.instance().rxnClasses.add(rxnClass); } }