本文整理了Java中rx.Observable.toMultimap()
方法的一些代码示例,展示了Observable.toMultimap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.toMultimap()
方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:toMultimap
[英]Returns an Observable that emits a single HashMap that contains an ArrayList of items emitted by the source Observable keyed by a specified keySelector function.
Backpressure Support: This operator does not support backpressure as by intent it is requesting and buffering everything. Scheduler: toMultiMap does not operate by default on a particular Scheduler.
[中]返回一个Observable,该Observable发出一个HashMap,该HashMap包含由指定keySelector函数键控的源Observable发出的项的ArrayList。
背压支持:该操作员无意支持背压,因为它正在请求和缓冲所有内容。调度器:默认情况下,toMultiMap不会在特定的调度器上运行。
代码示例来源:origin: spencergibb/myfeed
@RequestMapping("/init/all")
public Single<Map<String, Collection<FeedItem>>> initAll() {
return userService.getUsers()
.map(Resource::getContent)
.map(User::getUsername)
.flatMap(this::initUser)
.toMultimap(ufi -> ufi.username, ufi -> ufi.feedItem).toSingle();
}
代码示例来源:origin: io.wcm.caravan/io.wcm.caravan.io.http
@Override
public Map<String, String[]> getParameterMap() {
try {
List<NameValuePair> pairs = URLEncodedUtils.parse(new URI(request.getUrl()), Charsets.UTF_8.toString());
Map<String, Collection<String>> multiMap = Observable.from(pairs).toMultimap(NameValuePair::getName, NameValuePair::getValue).toBlocking().single();
Builder<String, String[]> builder = ImmutableMap.builder();
multiMap.entrySet().stream().forEach(entry -> {
String[] arrayValue = entry.getValue().toArray(new String[entry.getValue().size()]);
builder.put(entry.getKey(), arrayValue);
});
return builder.build();
}
catch (URISyntaxException ex) {
ex.printStackTrace();
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!