// Path: rx-renovate/src/main/java/renovate/rxjava/subscribe/ResultOnSubscribe.java
// public final class ResultOnSubscribe<T> implements OnSubscribe<Result<T>> {
//     private final OnSubscribe<Response<T>> upstream;
// 
//     public ResultOnSubscribe(OnSubscribe<Response<T>> upstream) {
//         this.upstream = upstream;
//     }
// 
//     @Override
//     public void call(Subscriber<? super Result<T>> subscriber) {
//         upstream.call(new ResultSubscriber<T>(subscriber));
//     }
// 
//     private static class ResultSubscriber<R> extends Subscriber<Response<R>> {
// 
//         private final Subscriber<? super Result<R>> subscriber;
// 
//         ResultSubscriber(Subscriber<? super Result<R>> subscriber) {
//             super(subscriber);
//             this.subscriber = subscriber;
//         }
// 
//         @Override
//         public void onNext(Response<R> response) {
//             subscriber.onNext(Result.response(response));
//         }
// 
//         @Override
//         public void onError(Throwable throwable) {
//             try {
//                 subscriber.onNext(Result.<R>error(throwable));
//             } catch (Throwable t) {
//                 try {
//                     subscriber.onError(t);
//                 } catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
//                     RxJavaHooks.getOnError().call(e);
//                 } catch (Throwable inner) {
//                     Exceptions.throwIfFatal(inner);
//                     RxJavaHooks.getOnError().call(new CompositeException(t, inner));
//                 }
//                 return;
//             }
//             subscriber.onCompleted();
//         }
// 
//         @Override
//         public void onCompleted() {
//             subscriber.onCompleted();
//         }
//     }
// }


import renovate.*;
import renovate.rxjava.subscribe.ResultOnSubscribe;
import rx.Observable;
/*
 * Copyright 2016 jeasonlzy(廖子尧)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package renovate.rxjava.adapter;



/**
 * ================================================
 * 作    者：jeasonlzy（廖子尧）Github地址：https://github.com/jeasonlzy
 * 版    本：1.0
 * 创建日期：2017/5/26
 * 描    述：
 * 修订历史：
 * ================================================
 */
public class ObservableResult<T> implements CallAdapter<T, Observable<Result<T>>> {
    @Override
    public Observable<Result<T>> adapt(Call<T> call, AdapterParam param) {
        Observable.OnSubscribe<Response<T>> subscribe = AnalysisParams.analysis(call, param);
// Path: rx-renovate/src/main/java/renovate/rxjava/subscribe/ResultOnSubscribe.java
// public final class ResultOnSubscribe<T> implements OnSubscribe<Result<T>> {
//     private final OnSubscribe<Response<T>> upstream;
// 
//     public ResultOnSubscribe(OnSubscribe<Response<T>> upstream) {
//         this.upstream = upstream;
//     }
// 
//     @Override
//     public void call(Subscriber<? super Result<T>> subscriber) {
//         upstream.call(new ResultSubscriber<T>(subscriber));
//     }
// 
//     private static class ResultSubscriber<R> extends Subscriber<Response<R>> {
// 
//         private final Subscriber<? super Result<R>> subscriber;
// 
//         ResultSubscriber(Subscriber<? super Result<R>> subscriber) {
//             super(subscriber);
//             this.subscriber = subscriber;
//         }
// 
//         @Override
//         public void onNext(Response<R> response) {
//             subscriber.onNext(Result.response(response));
//         }
// 
//         @Override
//         public void onError(Throwable throwable) {
//             try {
//                 subscriber.onNext(Result.<R>error(throwable));
//             } catch (Throwable t) {
//                 try {
//                     subscriber.onError(t);
//                 } catch (OnCompletedFailedException | OnErrorFailedException | OnErrorNotImplementedException e) {
//                     RxJavaHooks.getOnError().call(e);
//                 } catch (Throwable inner) {
//                     Exceptions.throwIfFatal(inner);
//                     RxJavaHooks.getOnError().call(new CompositeException(t, inner));
//                 }
//                 return;
//             }
//             subscriber.onCompleted();
//         }
// 
//         @Override
//         public void onCompleted() {
//             subscriber.onCompleted();
//         }
//     }
// }


// Path: rx-renovate/src/main/java/renovate/rxjava/adapter/ObservableResult.java
import renovate.*;
import renovate.rxjava.subscribe.ResultOnSubscribe;
import rx.Observable;

/*
 * Copyright 2016 jeasonlzy(廖子尧)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package renovate.rxjava.adapter;



/**
 * ================================================
 * 作    者：jeasonlzy（廖子尧）Github地址：https://github.com/jeasonlzy
 * 版    本：1.0
 * 创建日期：2017/5/26
 * 描    述：
 * 修订历史：
 * ================================================
 */
public class ObservableResult<T> implements CallAdapter<T, Observable<Result<T>>> {
    @Override
    public Observable<Result<T>> adapt(Call<T> call, AdapterParam param) {
        Observable.OnSubscribe<Response<T>> subscribe = AnalysisParams.analysis(call, param);
        ResultOnSubscribe<T> resultSubscribe = new ResultOnSubscribe<>(subscribe);