Skip to content

Commit

Permalink
Merge pull request square#414 from square/jw/useless-method
Browse files Browse the repository at this point in the history
Remove useless setApi method, take in constructor instead.
  • Loading branch information
loganj committed Feb 20, 2014
2 parents d9a5070 + 0ec74bb commit 42b1286
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions retrofit-mock/src/main/java/retrofit/MockRestAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,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.
Expand Down
9 changes: 3 additions & 6 deletions retrofit/src/main/java/retrofit/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Header> headers;

RequestBuilder(Converter converter, RestMethodInfo methodInfo) {
RequestBuilder(String apiUrl, RestMethodInfo methodInfo, Converter converter) {
this.apiUrl = apiUrl;
this.converter = converter;

paramNames = methodInfo.requestParamNames;
Expand Down Expand Up @@ -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.");
Expand Down
3 changes: 1 addition & 2 deletions retrofit/src/main/java/retrofit/RestAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,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);
Expand Down
3 changes: 1 addition & 2 deletions retrofit/src/test/java/retrofit/RequestBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
Expand Down

0 comments on commit 42b1286

Please sign in to comment.