示例#1
0
 private void ensureSaneDefaults() {
   if (converter == null) {
     converter = Platform.get().defaultConverter();
   }
   if (clientProvider == null) {
     clientProvider = Platform.get().defaultClient();
   }
   if (httpExecutor == null) {
     httpExecutor = Platform.get().defaultHttpExecutor();
   }
   if (callbackExecutor == null) {
     callbackExecutor = Platform.get().defaultCallbackExecutor();
   }
   if (headers == null) {
     headers = Headers.NONE;
   }
 }
示例#2
0
 private void eagerlyValidateMethods(Class<?> service) {
   Platform platform = Platform.get();
   for (Method method : service.getDeclaredMethods()) {
     if (!platform.isDefaultMethod(method)) {
       loadMethodHandler(method);
     }
   }
 }
示例#3
0
  @Override
  void getKnown(URI uri) {
    long[] ticks;

    synchronized (this) {
      ticks = _ticks != null ? Platform.get().clone(_ticks) : null;
    }

    if (ticks == null && !location().isCache()) ticks = Tick.EMPTY;

    if (ticks != null) uri.onKnown(this, ticks);
  }
示例#4
0
    /** Create the {@link Retrofit} instances. */
    public Retrofit build() {
      if (baseUrl == null) {
        throw new IllegalStateException("Base URL required.");
      }

      OkHttpClient client = this.client;
      if (client == null) {
        client = new OkHttpClient();
      }

      // Make a defensive copy of the adapters and add the default Call adapter.
      List<CallAdapter.Factory> adapterFactories = new ArrayList<>(this.adapterFactories);
      adapterFactories.add(Platform.get().defaultCallAdapterFactory(callbackExecutor));

      // Make a defensive copy of the converters.
      List<Converter.Factory> converterFactories = new ArrayList<>(this.converterFactories);

      return new Retrofit(
          client, baseUrl, converterFactories, adapterFactories, callbackExecutor, validateEagerly);
    }