List of usage examples for java.util.stream Stream parallel
S parallel();
From source file:org.hswebframework.web.service.authorization.simple.SimpleAuthorizationSettingService.java
private List<AuthorizationSettingEntity> getUserSetting(String userId) { Map<String, List<SettingInfo>> settingInfo = authorizationSettingTypeSuppliers.stream() .map(supplier -> supplier.get(userId)).flatMap(Set::stream) .collect(Collectors.groupingBy(SettingInfo::getType)); Stream<Map.Entry<String, List<SettingInfo>>> settingInfoStream = settingInfo.entrySet().stream(); //1 ?/*from w ww . j a va2s . c o m*/ if (settingInfo.size() > 1) { settingInfoStream = settingInfoStream.parallel(); } return settingInfoStream.map(entry -> createQuery() // where type = ? and setting_for in (?,?,?....) .where(type, entry.getKey()).and() .in(settingFor, entry.getValue().stream().map(SettingInfo::getSettingFor).collect(Collectors.toList())) .listNoPaging()).flatMap(List::stream).collect(Collectors.toList()); }
From source file:org.pdfsam.configuration.EnhancedClassloaderProvider.java
private static URL[] getUrls(Stream<Path> files) throws MalformedURLException { Set<URI> modules = files.parallel().filter(new JarSignatureFilter()).map(Path::toUri) .collect(Collectors.toSet()); // TODO remove all this cumbersome code once Eclipse stops complaining about uncaught exception when using stream.map List<URL> urls = new ArrayList<>(); for (URI module : modules) { urls.add(module.toURL());/* w w w . j av a 2 s.c o m*/ } return urls.toArray(new URL[urls.size()]); }