List of usage examples for java.util.stream Collectors toCollection
public static <T, C extends Collection<T>> Collector<T, ?, C> toCollection(Supplier<C> collectionFactory)
From source file:de.bund.bfr.knime.pmmlite.core.PmmUtils.java
public static void setId(SecondaryModel obj) { List<String> idParts = new ArrayList<>(); idParts.add(obj.eClass().getName()); idParts.add(obj.getFormula().getId()); idParts.add(String.valueOf(getIds(obj.getData()).hashCode())); idParts.add(String.valueOf(obj.getAssignments().stream().map(e -> new Pair<>(e.getKey(), e.getValue())) .collect(Collectors.toCollection(LinkedHashSet::new)).hashCode())); if (obj.getSse() != null) { idParts.add(String.valueOf(obj.getSse())); }/*from ww w . j a va 2 s . co m*/ obj.setId(createId(Joiner.on("_").join(idParts))); }
From source file:org.artifactory.features.VersionFeatures.java
/** * Returns features available for the given version * * @param version {@link VersionInfo} to check from (inclusive) * * @return List<VersionFeature>//from w ww .jav a2 s . c o m */ public List<VersionFeature> getFeaturesByVersion(VersionInfo version) { if (version == null) return Lists.newLinkedList(); return features.parallelStream().filter(n -> n.getAvailableFrom().compareTo(version) >= 0) .collect(Collectors.toCollection(LinkedList::new)); }
From source file:org.jamocha.dn.compiler.ecblocks.CEToECTranslator.java
@Override public void visit(final OrFunctionConditionalElement<ECLeaf> ce) { // For each child of the OrCE ... this.translateds = ce.getChildren().stream().map(child -> // ... collect all PathFilters in the child NoORsTranslator.consolidate(this.initialFactTemplate, this.rule, child)) .collect(Collectors.toCollection(ArrayList::new)); }
From source file:ch.sdi.core.impl.data.InputTransformerProperties.java
/** * Reads the ignored fields into member myIgnoredFields and returns a collection of all raw field * names which are not filtered (sdi.normalize.ignoreField). * <p>/*from w w w. ja va 2s . co m*/ * @param aFieldnames * the collected fieldnames * @return */ private Collection<String> getFilteredRawFieldNames(Collection<String> aFieldnames) { String value = myEnv.getProperty(SdiMainProperties.KEY_NORMALIZE_IGNORE_FIELD); if (!StringUtils.hasText(value)) { myLog.debug("no normalize field filters configured"); myIgnoredFields = new ArrayList<>(); return aFieldnames; } // if !StringUtils.hasText( value ) myIgnoredFields = Arrays.asList(value.split(",")); return aFieldnames.stream().filter(f -> !myIgnoredFields.contains(f)) .collect(Collectors.toCollection((Supplier<List<String>>) ArrayList::new)); }
From source file:org.lightjason.agentspeak.action.buildin.rest.IBaseRest.java
/** * creates a literal structure from a stream of string elements, * the string stream will be build in a tree structure * * @param p_functor stream with functor strings * @param p_values value stream// w w w.ja va2 s .co m * @return term */ protected static ITerm baseliteral(final Stream<String> p_functor, final Stream<ITerm> p_values) { final Stack<String> l_tree = p_functor.collect(Collectors.toCollection(Stack::new)); ILiteral l_literal = CLiteral.from(l_tree.pop(), p_values); while (!l_tree.isEmpty()) l_literal = CLiteral.from(l_tree.pop(), l_literal); return l_literal; }
From source file:com.wormsim.simulation.Walker.java
/** * For serialization - to be replaced?//from www. j a v a2s . com * * @param rng The random number generator to use. * @param seed The initial seed number (unused but important for * recording). * @param zoo The zoo to use. * @param fitness The fitness tracker * @param tracked_quantities Quantities tracked in the simulation. */ protected Walker(RandomGenerator rng, long seed, AnimalZoo2 zoo, TrackedCalculation fitness, ArrayList<TrackedCalculation> tracked_quantities) { this.rng = rng; this.seed = seed; this.zoo = zoo.generate(rng); this.fitness = fitness.generate(rng); this.tracked_quantities = tracked_quantities.stream().map((v) -> v.generate(rng)) .collect(Collectors.toCollection(ArrayList::new)); this.tracked_quantities.add(this.fitness); }
From source file:com.olacabs.fabric.compute.builder.impl.JarScanner.java
URL[] download(Collection<String> urls) { ArrayList<URL> downloadedURLs = urls.stream().map(url -> { URI uri = URI.create(url); String downloaderImplClassName = properties.getProperty(String.format("fs.%s.impl", uri.getScheme())); if (null == downloaderImplClassName) { throw new RuntimeException( new UnsupportedSchemeException(uri.getScheme() + " is not supported for downloading jars")); }//from w ww . j ava 2 s . c o m try { Class clazz = Class.forName(downloaderImplClassName); if (JarDownloader.class.isAssignableFrom(clazz)) { try { return ((JarDownloader) clazz.newInstance()).download(url).toUri().toURL(); } catch (Exception e) { throw new RuntimeException(e); } } else { throw new RuntimeException("Unsupported implementation " + downloaderImplClassName + " of " + JarDownloader.class.getSimpleName()); } } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }).collect(Collectors.toCollection(ArrayList::new)); return downloadedURLs.toArray(new URL[downloadedURLs.size()]); }
From source file:Imputers.KnniLDProb.java
public List<SingleGenotypeProbability> impute(double[][][] callprobs, int[][][] readCounts, List<SingleGenotypeProbability> maskedprobs, List<SingleGenotypeMasked> list) { ProbToCallMinDepth p2c = new ProbToCallMinDepth(knownDepth); byte[][] original = p2c.call(callprobs, readCounts); Correlation corr = new Pearson(); Set<Integer> ldcalc = list.stream().map(SingleGenotypePosition::getSNP) .collect(Collectors.toCollection(HashSet::new)); byte[][] transposed = Matrix.transpose(original); Map<Integer, int[]> ld; if (ldcalc.size() < (transposed.length / 2)) { ld = corr.limitedtopn(transposed, 100, ldcalc); } else {//from w w w. jav a2 s . c o m ld = corr.topn(transposed, 100); } int[][] sim = new int[original[0].length][]; for (Entry<Integer, int[]> e : ld.entrySet()) { sim[e.getKey()] = e.getValue(); } return impute(original, maskedprobs, list, sim); }
From source file:de.bund.bfr.knime.pmmlite.core.PmmUtils.java
public static void setId(TertiaryModel obj) { List<String> idParts = new ArrayList<>(); idParts.add(obj.eClass().getName()); idParts.add(obj.getFormula().getId()); idParts.add(String.valueOf(getIds(obj.getData()).hashCode())); idParts.add(String.valueOf(obj.getAssignments().stream().map(e -> new Pair<>(e.getKey(), e.getValue())) .collect(Collectors.toCollection(LinkedHashSet::new)).hashCode())); if (obj.getSse() != null) { idParts.add(String.valueOf(obj.getSse())); }/* www . ja v a 2s .c om*/ obj.setId(createId(Joiner.on("_").join(idParts))); }
From source file:com.mycompany.wolf.Room.java
public void removePlayer(String playerId) throws IOException { synchronized (mutex) { sessions.removeIf(equalityPredicate(playerId)); List<Map<String, String>> roomInfo = sessions.stream() .map(s -> ImmutableMap.of("playerId", getPlayerId(s))) .collect(Collectors.toCollection(LinkedList::new)); Map<String, Object> m = ImmutableMap.of("code", "exitResp", "properties", roomInfo); String json = new Gson().toJson(m); sessions.stream().forEach(s -> { s.getAsyncRemote().sendText(json); });/*w w w .j ava 2s. c o m*/ } RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(3000).setConnectTimeout(3000).build(); CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom().setDefaultRequestConfig(requestConfig) .build(); httpclient.start(); try { String routerAddress = SpringContext.getBean("routerAddress"); httpclient.execute(new HttpGet(routerAddress), new FutureCallback<HttpResponse>() { @Override public void completed(HttpResponse t) { } @Override public void failed(Exception excptn) { } @Override public void cancelled() { } }); } finally { httpclient.close(); } }