List of usage examples for java.util Set stream
default Stream<E> stream()
From source file:Main.java
public static void main(String[] args) { Set<String> names = new HashSet<>(); names.add("XML"); names.add("Java"); Stream<String> sequentialStream = names.stream(); sequentialStream.forEach(System.out::println); Stream<String> parallelStream = names.parallelStream(); parallelStream.forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { Set<Integer> numberSet = new HashSet<Integer>() { {//from w w w . jav a2s . c o m add(1); add(2); add(3); } }; Stream<Integer> collectionStream = numberSet.stream(); System.out.println(Arrays.toString(collectionStream.toArray())); }
From source file:com.ginema.api.reflection.ReflectionUtils.java
public static boolean isAssignableFrom(Class c, Set<Class> allowedClasses) { return allowedClasses.stream().filter(clazz -> ClassUtils.isAssignable(c, clazz, true)).findFirst() .isPresent();//from w w w . j a v a2s . c o m }
From source file:edu.pitt.dbmi.ccd.db.specification.GroupSpecification.java
private static List<Predicate> inNameOrDescription(Root<Group> root, CriteriaBuilder cb, Set<String> terms) { return terms.stream().map(t -> containsLike(t)) .map(t -> cb.or(nameContains(root, cb, t), descriptionContains(root, cb, t))) .collect(Collectors.toList()); }
From source file:edu.pitt.dbmi.ccd.db.specification.GroupSpecification.java
private static List<Predicate> notInNameOrDescription(Root<Group> root, CriteriaBuilder cb, Set<String> terms) { return terms.stream().map(t -> containsLike(t)) .map(t -> cb.not(cb.or(nameContains(root, cb, t), descriptionContains(root, cb, t)))) .collect(Collectors.toList()); }
From source file:edu.pitt.dbmi.ccd.db.specification.VocabularySpecification.java
private static List<Predicate> inNameOrDescription(Root<Vocabulary> root, CriteriaBuilder cb, Set<String> terms) { return terms.stream().map(t -> containsLike(t)) .map(t -> cb.or(nameContains(root, cb, t), descriptionContains(root, cb, t))) .collect(Collectors.toList()); }
From source file:edu.pitt.dbmi.ccd.db.specification.VocabularySpecification.java
private static List<Predicate> notInNameOrDescription(Root<Vocabulary> root, CriteriaBuilder cb, Set<String> terms) { return terms.stream().map(t -> containsLike(t)) .map(t -> cb.not(cb.or(nameContains(root, cb, t), descriptionContains(root, cb, t)))) .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 . j ava2 s . c om 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:io.neba.core.util.JsonUtil.java
/** * @param map must not be <code>null</code>. *///from w w w.jav a 2 s. c om public static String toJson(Map<?, ?> map) { if (map == null) { throw new IllegalArgumentException("Method parameter map must not be null"); } Set<? extends Map.Entry<?, ?>> entries = map.entrySet(); return entries.stream().map(e -> toJson(e.getKey()) + ':' + toJson(e.getValue())) .reduce((l, r) -> l + ',' + r).map(s -> '{' + s + '}').orElse("{}"); }
From source file:com.cloudera.oryx.example.batch.ExampleBatchLayerUpdate.java
public static Map<String, Integer> countDistinctOtherWords(JavaPairRDD<String, String> data) { return data.values().flatMapToPair(line -> { Set<String> distinctTokens = new HashSet<>(Arrays.asList(line.split(" "))); return distinctTokens.stream() .flatMap(a -> distinctTokens.stream().filter(b -> !a.equals(b)).map(b -> new Tuple2<>(a, b))) .iterator();// w ww . j a v a 2 s . c om }).distinct().mapValues(a -> 1).reduceByKey((c1, c2) -> c1 + c2).collectAsMap(); }