retrofit2.Call.clone()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中retrofit2.Call.clone()方法的一些代码示例,展示了Call.clone()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Call.clone()方法的具体详情如下:
包路径:retrofit2.Call
类名称:Call
方法名:clone

Call.clone介绍

[英]Create a new, identical call to this one which can be enqueued or executed even if this call has already been.
[中]创建一个与此调用相同的新调用,该调用可以排队或执行,即使此调用已经完成。

代码示例

代码示例来源:origin: resilience4j/resilience4j

@Override
public Call<T> clone() {
  return call.clone();
}

代码示例来源:origin: square/retrofit

@Override public MyCall<T> clone() {
  return new MyCallAdapter<>(call.clone(), callbackExecutor);
 }
}

代码示例来源:origin: square/retrofit

@SuppressWarnings("CloneDoesntCallSuperClone") // Performing deep clone.
@Override public Call<T> clone() {
 return new ExecutorCallbackCall<>(callbackExecutor, delegate.clone());
}

代码示例来源:origin: square/retrofit

@SuppressWarnings("CloneDoesntCallSuperClone") // We are a final type & this saves clearing state.
@Override public Call<T> clone() {
 return new BehaviorCall<>(behavior, backgroundExecutor, delegate.clone());
}

代码示例来源:origin: square/retrofit

@Override protected void subscribeActual(Observer<? super Response<T>> observer) {
 // Since Call is a one-shot type, clone it for each new observer.
 Call<T> call = originalCall.clone();
 CallCallback<T> callback = new CallCallback<>(call, observer);
 observer.onSubscribe(callback);
 if (!callback.isDisposed()) {
  call.enqueue(callback);
 }
}

代码示例来源:origin: com.squareup.retrofit2/retrofit

@SuppressWarnings("CloneDoesntCallSuperClone") // Performing deep clone.
@Override public Call<T> clone() {
 return new ExecutorCallbackCall<>(callbackExecutor, delegate.clone());
}

代码示例来源:origin: square/retrofit

@Override public void call(Subscriber<? super Response<T>> subscriber) {
  // Since Call is a one-shot type, clone it for each new subscriber.
  Call<T> call = originalCall.clone();
  final CallArbiter<T> arbiter = new CallArbiter<>(call, subscriber);
  subscriber.add(arbiter);
  subscriber.setProducer(arbiter);

  call.enqueue(new Callback<T>() {
   @Override public void onResponse(Call<T> call, Response<T> response) {
    arbiter.emitResponse(response);
   }

   @Override public void onFailure(Call<T> call, Throwable t) {
    Exceptions.throwIfFatal(t);
    arbiter.emitError(t);
   }
  });
 }
}

代码示例来源:origin: square/retrofit

@Override public void call(Subscriber<? super Response<T>> subscriber) {
  // Since Call is a one-shot type, clone it for each new subscriber.
  Call<T> call = originalCall.clone();
  CallArbiter<T> arbiter = new CallArbiter<>(call, subscriber);
  subscriber.add(arbiter);
  subscriber.setProducer(arbiter);

  Response<T> response;
  try {
   response = call.execute();
  } catch (Throwable t) {
   Exceptions.throwIfFatal(t);
   arbiter.emitError(t);
   return;
  }
  arbiter.emitResponse(response);
 }
}

代码示例来源:origin: resilience4j/resilience4j

@Test
public void passThroughCallsToDecoratedObject() throws IOException {
  final Call<String> call = mock(StringCall.class);
  final Call<String> decorated = new DecoratedCall<>(call);
  decorated.cancel();
  Mockito.verify(call).cancel();
  decorated.enqueue(null);
  Mockito.verify(call).enqueue(any());
  decorated.isExecuted();
  Mockito.verify(call).isExecuted();
  decorated.isCanceled();
  Mockito.verify(call).isCanceled();
  decorated.clone();
  Mockito.verify(call).clone();
  decorated.request();
  Mockito.verify(call).request();
  decorated.execute();
  Mockito.verify(call).execute();
}

代码示例来源:origin: square/retrofit

@Override protected void subscribeActual(Observer<? super Response<T>> observer) {
 Call<T> call = originalCall.clone();
 CallDisposable disposable = new CallDisposable(call);
 observer.onSubscribe(disposable);

代码示例来源:origin: mapbox/mapbox-java

/**
 * Wrapper method for Retrofit's {@link Call#clone()} call, useful for getting call information.
 *
 * @return cloned call
 * @since 3.5.0
 */
public Call<List<FeatureCollection>> cloneBatchCall() {
 return getBatchCall().clone();
}

代码示例来源:origin: gradle.plugin.de.qaware.cloud.deployer/deployer

/**
 * Retries a call after a waiting period.
 *
 * @return The response of the call.
 */
private Response<ResponseBody> retryCall(Call<ResponseBody> call) throws IOException, InterruptedException {
  Thread.sleep(SERVER_ERROR_WAITING_TIME * 1000);
  return call.clone().execute();
}

代码示例来源:origin: mapbox/mapbox-java

/**
 * Wrapper method for Retrofits {@link Call#clone()} call, useful for getting call information.
 *
 * @return cloned call
 * @since 1.0.0
 */
public Call<List<GeocodingResponse>> cloneBatchCall() {
 return getBatchCall().clone();
}

代码示例来源:origin: mapbox/mapbox-java

/**
 * Wrapper method for Retrofit's {@link Call#clone()} call, useful for getting call information.
 *
 * @return cloned call
 * @since 3.5.0
 */
public Call<List<FeatureCollection>> cloneBatchCall() {
 return getBatchCall().clone();
}

代码示例来源:origin: mapbox/mapbox-java

/**
 * Wrapper method for Retrofits {@link Call#clone()} call, useful for getting call information.
 *
 * @return cloned call
 * @since 3.0.0
 */
public Call<T> cloneCall() {
 return getCall().clone();
}

代码示例来源:origin: com.mapbox.mapboxsdk/mapbox-sdk-services

/**
 * Wrapper method for Retrofits {@link Call#clone()} call, useful for getting call information.
 *
 * @return cloned call
 * @since 1.0.0
 */
public Call<List<GeocodingResponse>> cloneBatchCall() {
 return getBatchCall().clone();
}

代码示例来源:origin: VictorAlbertos/Mockery

@Override public Object adaptResponse(Object response, Metadata<Retrofit> metadata) {
 checkReturnMethodTypeIsCall(metadata);
 Call call = (Call) response;
 try {
  Response payload = call.clone().execute();
  Object body = payload.body();
  return body;
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: JakeWharton/retrofit2-reactor-adapter

@Override public void accept(FluxSink<Response<T>> sink) {
 // Since Call is a one-shot type, clone it for each new subscriber.
 Call<T> call = originalCall.clone();
 DisposableCallback<T> callback = new DisposableCallback<>(call, sink);
 sink.onDispose(callback);
 call.enqueue(callback);
}

代码示例来源:origin: iagocanalejas/retrocache

@Override
public Cached<T> clone() {
  return new CachedCall<>(mExecutor, mCall.clone(), responseType(),
      mAnnotations, mRetrofit, mCachingSystem);
}

代码示例来源:origin: lizubing1992/Smartcacheforretrofit2

@Override
public SmartCall<T> clone() {
  return new SmartCallImpl<>(callbackExecutor, baseCall.clone(), responseType(),
      annotations, retrofit, cachingSystem);
}

相关文章