From 0ec74bb51fc20648f33d1a8f2ee8b90f0c17b2e4 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Thu, 20 Feb 2014 12:29:47 -0800 Subject: [PATCH] Remove useless setApi method, take in constructor instead. --- .../src/main/java/retrofit/MockRestAdapter.java | 4 ++-- retrofit/src/main/java/retrofit/RequestBuilder.java | 9 +++------ retrofit/src/main/java/retrofit/RestAdapter.java | 3 +-- retrofit/src/test/java/retrofit/RequestBuilderTest.java | 3 +-- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/retrofit-mock/src/main/java/retrofit/MockRestAdapter.java b/retrofit-mock/src/main/java/retrofit/MockRestAdapter.java index 25c02dac55..7fd68b2657 100644 --- a/retrofit-mock/src/main/java/retrofit/MockRestAdapter.java +++ b/retrofit-mock/src/main/java/retrofit/MockRestAdapter.java @@ -267,8 +267,8 @@ private Request buildRequest(RestMethodInfo methodInfo, RequestInterceptor inter methodInfo.init(); // Begin building a normal request. - RequestBuilder requestBuilder = new RequestBuilder(restAdapter.converter, methodInfo); - requestBuilder.setApiUrl(restAdapter.server.getUrl()); + String apiUrl = restAdapter.server.getUrl(); + RequestBuilder requestBuilder = new RequestBuilder(apiUrl, methodInfo, restAdapter.converter); requestBuilder.setArguments(args); // Run it through the interceptor. diff --git a/retrofit/src/main/java/retrofit/RequestBuilder.java b/retrofit/src/main/java/retrofit/RequestBuilder.java index 5525b9a8f5..725094aa2a 100644 --- a/retrofit/src/main/java/retrofit/RequestBuilder.java +++ b/retrofit/src/main/java/retrofit/RequestBuilder.java @@ -39,17 +39,18 @@ final class RequestBuilder implements RequestInterceptor.RequestFacade { private final String requestMethod; private final boolean isSynchronous; private final boolean isObservable; + private final String apiUrl; private final FormUrlEncodedTypedOutput formBody; private final MultipartTypedOutput multipartBody; private TypedOutput body; - private String apiUrl; private String relativeUrl; private StringBuilder queryParams; private List
headers; - RequestBuilder(Converter converter, RestMethodInfo methodInfo) { + RequestBuilder(String apiUrl, RestMethodInfo methodInfo, Converter converter) { + this.apiUrl = apiUrl; this.converter = converter; paramNames = methodInfo.requestParamNames; @@ -90,10 +91,6 @@ final class RequestBuilder implements RequestInterceptor.RequestFacade { } } - void setApiUrl(String apiUrl) { - this.apiUrl = apiUrl; - } - @Override public void addHeader(String name, String value) { if (name == null) { throw new IllegalArgumentException("Header name must not be null."); diff --git a/retrofit/src/main/java/retrofit/RestAdapter.java b/retrofit/src/main/java/retrofit/RestAdapter.java index 0739651ba3..8a8e6b01a0 100644 --- a/retrofit/src/main/java/retrofit/RestAdapter.java +++ b/retrofit/src/main/java/retrofit/RestAdapter.java @@ -329,8 +329,7 @@ private Object invokeRequest(RequestInterceptor requestInterceptor, String serverUrl = server.getUrl(); String url = serverUrl; // Keep some url in case RequestBuilder throws an exception. try { - RequestBuilder requestBuilder = new RequestBuilder(converter, methodInfo); - requestBuilder.setApiUrl(serverUrl); + RequestBuilder requestBuilder = new RequestBuilder(serverUrl, methodInfo, converter); requestBuilder.setArguments(args); requestInterceptor.intercept(requestBuilder); diff --git a/retrofit/src/test/java/retrofit/RequestBuilderTest.java b/retrofit/src/test/java/retrofit/RequestBuilderTest.java index 525024456f..850a8b3014 100644 --- a/retrofit/src/test/java/retrofit/RequestBuilderTest.java +++ b/retrofit/src/test/java/retrofit/RequestBuilderTest.java @@ -890,7 +890,7 @@ Request build() throws Exception { methodInfo.headers = headers; methodInfo.loaded = true; - RequestBuilder requestBuilder = new RequestBuilder(GSON, methodInfo); + RequestBuilder requestBuilder = new RequestBuilder(url, methodInfo, GSON); // Simulate request interceptor invocation. for (Header header : interceptorHeaders) { @@ -903,7 +903,6 @@ Request build() throws Exception { requestBuilder.addQueryParam(entry.getKey(), entry.getValue()); } - requestBuilder.setApiUrl(url); requestBuilder.setArguments(args.toArray(new Object[args.size()])); return requestBuilder.build();