当前位置: 首页>>代码示例>>Java>>正文


Java Single.map方法代码示例

本文整理汇总了Java中io.reactivex.Single.map方法的典型用法代码示例。如果您正苦于以下问题:Java Single.map方法的具体用法?Java Single.map怎么用?Java Single.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.Single的用法示例。


在下文中一共展示了Single.map方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import io.reactivex.Single; //导入方法依赖的package包/类
private static Single<TmpResult> init(Single<Entry> single) {
    return single.map(entry -> {
        TmpResult result = new TmpResult(entry.getId(), entry.getAccountId(), entry.count());
        FullAndNonFullUpdates updates = entry.getUpdates();

        if (updates.hasFullMessages()) {
            for (AddMessageUpdate update : updates.getFullMessages()) {
                result.add(update.getMessageId())
                        .setDto(Dto2Model.transform(entry.getAccountId(), update));
            }
        }

        if (updates.hasNonFullMessages()) {
            for (Integer id : updates.getNonFull()) {
                result.add(id);
            }
        }
        return result;
    });
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:21,代码来源:RealtimeMessagesProcessor.java

示例2: getForecast

import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<Channel> getForecast(final String location) {
    // TODO escape location
    String yql = String.format(GET_FORECAST_FORMAT_STR, location);
    Single<Response<WeatherResponse>> single = weatherService.getByYql(yql);
    return single.map(new Function<Response<WeatherResponse>, Channel>() {
        @Override
        public Channel apply(Response<WeatherResponse> response) throws Exception {
            Results results = response.body().getQuery().getResults();
            if (results == null) {
                throw new LocationNotFoundError(location);
            }
            return results.getChannel();
        }
    });
}
 
开发者ID:tobyhs,项目名称:WeatherWeight,代码行数:17,代码来源:WeatherRepositoryImpl.java

示例3: getPlaylistsBy

import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<List<PlaylistEntity>> getPlaylistsBy(List<String> categories) {
    if(categories!=null) {
        Single<List<PlaylistEntity>> start = Single.just(new LinkedList<>());
        for(String category:categories){
            start=Single.zip(start,service.searchPlaylists(PlaylistEntity
                    .Filter.start()
                    .byName(category)
                    .limit(100)
                    .createOptions())
                    .onErrorResumeNext(Single.just(new ArrayList<>())),(first,second)->{
                if(second!=null){
                    first.addAll(second);
                }
                return first;
            });
        }
        return start.map(filter::filterPlaylists);
    }
    return Single.error(new IllegalArgumentException("categories are null"));
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:22,代码来源:MusicRemoteSource.java

示例4: getTracksBy

import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<List<TrackEntity>> getTracksBy(List<String> categories) {
    if(categories!=null) {
        Single<List<TrackEntity>> start = Single.just(new LinkedList<>());
        for(String category:categories){
            start=Single.zip(start,service.searchTracks(TrackEntity
                    .Filter.start()
                    .byTags(category)
                    .createOptions())
                    .onErrorResumeNext(Single.just(new ArrayList<>())),(first,second)->{
                if(second!=null){
                    first.addAll(second);
                }
                return first;
            });
        }
        return start.map(filter::filterTracks);
    }
    return Single.error(new IllegalArgumentException("categories are null"));
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:21,代码来源:MusicRemoteSource.java

示例5: from

import io.reactivex.Single; //导入方法依赖的package包/类
/**
 * Create a new step with a single that always returns a value.
 *
 * @param stepDataSingle - a single that returns a result for this step.
 * @param <T> type of return value (if any) for this step.
 * @param <A> type of {@link ActionableItem} this step returns when finished
 * @return a new {@link Step}.
 */
public static <T, A extends ActionableItem> Step<T, A> from(Single<Data<T, A>> stepDataSingle) {
  return new Step<>(
      stepDataSingle.map(
          new Function<Data<T, A>, Optional<Data<T, A>>>() {
            @Override
            public Optional<Data<T, A>> apply(Data<T, A> data) throws Exception {
              return Optional.of(data);
            }
          }));
}
 
开发者ID:uber,项目名称:RIBs,代码行数:19,代码来源:Step.java

示例6: apply

import io.reactivex.Single; //导入方法依赖的package包/类
@Override public SingleSource<Optional<T>> apply(Single<DataSnapshot> upstream) {
  return upstream.map(new Function<DataSnapshot, Optional<T>>() {
    @Override public Optional<T> apply(DataSnapshot dataSnapshot) throws Exception {
      return Optional.of(dataSnapshot.getValue(clazz));
    }
  });
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:8,代码来源:SingleTransformerOfClazz.java

示例7: apply

import io.reactivex.Single; //导入方法依赖的package包/类
@Override public SingleSource<Optional<T>> apply(Single<DataSnapshot> upstream) {
  return upstream.map(new Function<DataSnapshot, Optional<T>>() {
    @Override public Optional<T> apply(DataSnapshot dataSnapshot) throws Exception {
      return Optional.of(dataSnapshot.getValue(typeIndicator));
    }
  });
}
 
开发者ID:b3er,项目名称:RxFirebase2,代码行数:8,代码来源:SingleTransformerOfGenericTypeIndicator.java

示例8: postMessage

import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<Empty> postMessage(Single<ChatProto.ChatMessage> request) {
    return request.map(this::broadcast);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:5,代码来源:ChatImpl.java

示例9: oneToOne

import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<Message> oneToOne(Single<Message> request) {
    return request.map(this::maybeExplode);
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:5,代码来源:TckService.java


注:本文中的io.reactivex.Single.map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。