Skip to content

Commit

Permalink
Merge pull request square#628 from square/jw/remove-deprecated-methods
Browse files Browse the repository at this point in the history
Remove deprecated explicit encoded annotations.
  • Loading branch information
swankjesse committed Oct 9, 2014
2 parents 606ceda + 4fe65df commit fa3965f
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 230 deletions.
19 changes: 0 additions & 19 deletions retrofit/src/main/java/retrofit/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
import retrofit.client.Request;
import retrofit.converter.Converter;
import retrofit.http.Body;
import retrofit.http.EncodedPath;
import retrofit.http.EncodedQuery;
import retrofit.http.EncodedQueryMap;
import retrofit.http.Field;
import retrofit.http.FieldMap;
import retrofit.http.Part;
Expand Down Expand Up @@ -243,32 +240,16 @@ void setArguments(Object[] args) {
"Path parameter \"" + name + "\" value must not be null.");
}
addPathParam(name, value.toString(), path.encode());
} else if (annotationType == EncodedPath.class) {
String name = ((EncodedPath) annotation).value();
if (value == null) {
throw new IllegalArgumentException(
"Path parameter \"" + name + "\" value must not be null.");
}
addPathParam(name, value.toString(), false);
} else if (annotationType == Query.class) {
if (value != null) { // Skip null values.
Query query = (Query) annotation;
addQueryParam(query.value(), value, query.encodeName(), query.encodeValue());
}
} else if (annotationType == EncodedQuery.class) {
if (value != null) { // Skip null values.
EncodedQuery query = (EncodedQuery) annotation;
addQueryParam(query.value(), value, false, false);
}
} else if (annotationType == QueryMap.class) {
if (value != null) { // Skip null values.
QueryMap queryMap = (QueryMap) annotation;
addQueryParamMap(i, (Map<?, ?>) value, queryMap.encodeNames(), queryMap.encodeValues());
}
} else if (annotationType == EncodedQueryMap.class) {
if (value != null) { // Skip null values.
addQueryParamMap(i, (Map<?, ?>) value, false, false);
}
} else if (annotationType == retrofit.http.Header.class) {
if (value != null) { // Skip null values.
String name = ((retrofit.http.Header) annotation).value();
Expand Down
16 changes: 1 addition & 15 deletions retrofit/src/main/java/retrofit/RestMethodInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
import java.util.regex.Pattern;
import retrofit.client.Response;
import retrofit.http.Body;
import retrofit.http.EncodedPath;
import retrofit.http.EncodedQuery;
import retrofit.http.EncodedQueryMap;
import retrofit.http.Field;
import retrofit.http.FieldMap;
import retrofit.http.FormUrlEncoded;
Expand All @@ -43,8 +40,8 @@
import retrofit.http.Path;
import retrofit.http.Query;
import retrofit.http.QueryMap;
import retrofit.http.Streaming;
import retrofit.http.RestMethod;
import retrofit.http.Streaming;
import rx.Observable;

/** Request metadata about a service interface declaration. */
Expand Down Expand Up @@ -332,23 +329,12 @@ private void parseParameters() {
if (methodAnnotationType == Path.class) {
String name = ((Path) methodParameterAnnotation).value();
validatePathName(i, name);
} else if (methodAnnotationType == EncodedPath.class) {
String name = ((EncodedPath) methodParameterAnnotation).value();
validatePathName(i, name);
} else if (methodAnnotationType == Query.class) {
// Nothing to do.
} else if (methodAnnotationType == EncodedQuery.class) {
// Nothing to do.
} else if (methodAnnotationType == QueryMap.class) {
if (!Map.class.isAssignableFrom(methodParameterType)) {
throw parameterError(i, "@QueryMap parameter type must be Map.");
}

} else if (methodAnnotationType == EncodedQueryMap.class) {
if (!Map.class.isAssignableFrom(methodParameterType)) {
throw parameterError(i, "@EncodedQueryMap parameter type must be Map.");
}

} else if (methodAnnotationType == Header.class) {
// Nothing to do.
} else if (methodAnnotationType == Field.class) {
Expand Down
46 changes: 0 additions & 46 deletions retrofit/src/main/java/retrofit/http/EncodedPath.java

This file was deleted.

42 changes: 0 additions & 42 deletions retrofit/src/main/java/retrofit/http/EncodedQuery.java

This file was deleted.

41 changes: 0 additions & 41 deletions retrofit/src/main/java/retrofit/http/EncodedQueryMap.java

This file was deleted.

67 changes: 0 additions & 67 deletions retrofit/src/test/java/retrofit/RequestBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
import retrofit.converter.GsonConverter;
import retrofit.http.Body;
import retrofit.http.DELETE;
import retrofit.http.EncodedPath;
import retrofit.http.EncodedQuery;
import retrofit.http.EncodedQueryMap;
import retrofit.http.Field;
import retrofit.http.FieldMap;
import retrofit.http.FormUrlEncoded;
Expand Down Expand Up @@ -743,20 +740,6 @@ Response method(@Path(value = "ping", encode = false) String ping) {
assertThat(request.getBody()).isNull();
}

@Test public void getWithEncodedPathParamDeprecated() {
class Example {
@GET("/foo/bar/{ping}/") //
Response method(@EncodedPath("ping") String ping) {
return null;
}
}
Request request = buildRequest(Example.class, "po%20ng");
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getHeaders()).isEmpty();
assertThat(request.getUrl()).isEqualTo("http://example.com/foo/bar/po%20ng/");
assertThat(request.getBody()).isNull();
}

@Test public void getWithInterceptorPathParam() {
class Example {
@GET("/foo/bar/{ping}/") //
Expand Down Expand Up @@ -963,20 +946,6 @@ Response method(@Query(value = "pi ng", encodeName = true, encodeValue = false)
assertThat(request.getBody()).isNull();
}

@Test public void getWithEncodedQueryParamDeprecated() {
class Example {
@GET("/foo/bar/") //
Response method(@EncodedQuery("ping") String ping) {
return null;
}
}
Request request = buildRequest(Example.class, "p+o+n+g");
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getHeaders()).isEmpty();
assertThat(request.getUrl()).isEqualTo("http://example.com/foo/bar/?ping=p+o+n+g");
assertThat(request.getBody()).isNull();
}

@Test public void queryParamOptionalOmitsQuery() {
class Example {
@GET("/foo/bar/") //
Expand Down Expand Up @@ -1157,26 +1126,6 @@ Response method(@QueryMap Map<String, Object> query) {
assertThat(request.getBody()).isNull();
}

@Test public void getWithEncodedQueryParamMapDeprecated() {
class Example {
@GET("/foo/bar/") //
Response method(@EncodedQueryMap Map<String, Object> query) {
return null;
}
}

Map<String, Object> params = new LinkedHashMap<String, Object>();
params.put("kit", "k%20t");
params.put("foo", null);
params.put("ping", "p%20g");

Request request = buildRequest(Example.class, params);
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getHeaders()).isEmpty();
assertThat(request.getUrl()).isEqualTo("http://example.com/foo/bar/?kit=k%20t&ping=p%20g");
assertThat(request.getBody()).isNull();
}

@Test public void getWithEncodedQueryParamMap() {
class Example {
@GET("/foo/bar/") //
Expand Down Expand Up @@ -1238,22 +1187,6 @@ Response method(
assertThat(request.getBody()).isNull();
}

@Test public void encodedQueryMapMustBeAMap() {
class Example {
@GET("/") //
Response method(@EncodedQueryMap List<String> a) {
return null;
}
}
try {
buildRequest(Example.class);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage(
"Example.method: @EncodedQueryMap parameter type must be Map. (parameter #1)");
}
}

@Test public void normalPostWithPathParam() {
class Example {
@POST("/foo/bar/{ping}/") //
Expand Down

0 comments on commit fa3965f

Please sign in to comment.