List of usage examples for java.util.stream Collectors toList
public static <T> Collector<T, ?, List<T>> toList()
From source file:com.amazon.proposalcalculator.reader.StandByInstances.java
public static List<Price> generate(List<Price> beanList) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { Predicate<Price> predicate = c4LargeToBeCloned(); List<Price> t2NanoToBeClonedList = beanList.stream().filter(predicate).collect(Collectors.toList()); beanList = cloneT2Nano(beanList, t2NanoToBeClonedList); return beanList; }
From source file:Main.java
public static <T> Collection<T> removeNodes(T[] array, T sampleNode) { return Arrays.stream(array).filter((node) -> node != null ? !node.equals(sampleNode) : false) .collect(Collectors.toList()); }
From source file:com.hengyi.japp.tools.PYUtil.java
public static List<String> getFirstSpell(String cs) { if (isBlank(cs)) { return null; }/*from w w w .ja v a 2s .c o m*/ List<String> result = null; List<Set<Character>> cs_fpys = cs.chars().mapToObj(i -> toHanyuPinyinStringArray((char) i)) .map(a -> Arrays.stream(a).map(s -> s.charAt(0)).collect(Collectors.toSet())) .collect(Collectors.toList()); for (Set<Character> fpys : cs_fpys) { if (result == null) { result = fpys.stream().map(String::valueOf).collect(Collectors.toList()); } else { Stream<String> tmps = result.stream().flatMap(s -> fpys.stream().map(fpy -> s + fpy)); result = tmps.collect(Collectors.toList()); } } return result; }
From source file:Main.java
public static <T> List<T> conjunctCollections(Collection<T> list1, Collection<T> list2) { Set<T> set = new HashSet<>(list2); return list1.stream().filter(set::contains).collect(Collectors.toList()); }
From source file:Main.java
static List<File> exists(Collection<File> files) { return files.stream().filter(File::exists).collect(Collectors.toList()); }
From source file:com.openshift.restclient.utils.BeanUtils.java
/** * Convert a delimited string to camelcase (e.g. foo-bar -> fooBar) * @param name the string to convert * @param delimiter the delimiter to use * @return the delimited string camelcased *//*from w w w .j a v a 2 s .c o m*/ public static String toCamelCase(String name, String delimiter) { String[] parts = name.split("-"); List<String> capitalized = Stream.of(parts).map(p -> StringUtils.capitalize(p)) .collect(Collectors.toList()); return StringUtils.uncapitalize(StringUtils.join(capitalized, "")); }
From source file:Main.java
/** * Collect the return values of all the futures provided * * @param futures//from w ww . j a v a 2s .c o m * the futures the result is collected from * @return a future with the collected results */ @SafeVarargs public static <T> CompletableFuture<List<T>> collect(CompletableFuture<T>... futures) { return CompletableFuture.allOf(futures) .thenApply(v -> Stream.of(futures).map(f -> f.join()).collect(Collectors.toList())); }
From source file:com.firewallid.util.FIUtils.java
public static List<Tuple2<String, Integer>> setToTupleList(Set<String> set) { List<Tuple2<String, Integer>> tupleList = set.parallelStream() .map((String s) -> new Tuple2<String, Integer>(s, 1)).collect(Collectors.toList()); return tupleList; }
From source file:com.spotify.styx.api.deprecated.BackfillsPayload.java
public static BackfillsPayload create(com.spotify.styx.api.BackfillsPayload backfillsPayload) { return new AutoValue_BackfillsPayload( backfillsPayload.backfills().stream().map(BackfillPayload::create).collect(Collectors.toList())); }
From source file:org.hyperledger.examples.dropwizard.BlockRepresentation.java
public static BlockRepresentation create(APIBlock block) { return new BlockRepresentation(block.getID(), block.getPreviousID(), block.getHeight(), block.getLocalCreateTime(), block.getNonce(), block.getVersion(), block.getMerkleRoot(), block.getDifficultyTarget(), block.getTransactions().stream().map(Transaction::getID).collect(Collectors.toList())); }