added missing put methods with TypedKey

This commit is contained in:
Inderjeet Singh 2010-04-21 00:02:25 +00:00
parent 00b5d77fa6
commit e7e2e59f73
4 changed files with 14 additions and 5 deletions

View File

@ -30,6 +30,7 @@ class ContentBody extends ParamMap {
super(spec, contents);
}
@Override
public ContentBodySpec getSpec() {
return (ContentBodySpec) spec;
}

View File

@ -31,6 +31,7 @@ public final class HeaderMap extends ParamMap {
super(spec);
}
@Override
public <T> Builder put(TypedKey<T> paramKey, T content) {
return put(paramKey.getName(), content);
}

View File

@ -32,9 +32,6 @@ class ParamMap {
/**
* If value is a generic type, use {@link #put(String, Object, Type)} instead.
*
* @param key
* @param value
*/
public Builder<T> put(String paramName, Object content) {
return put(paramName, content, content.getClass());
@ -45,6 +42,11 @@ class ParamMap {
contents.put(paramName, content);
return this;
}
public <K> Builder<T> put(TypedKey<K> paramKey, K param) {
contents.put(paramKey.getName(), param);
return this;
}
}
protected final Map<String, Object> contents;

View File

@ -22,7 +22,7 @@ import java.util.Map;
* Definition of the request body of a {@link WebServiceCall}. The request body is what is sent out
* in the output stream of the request (for example, with
* {@link java.net.HttpURLConnection#getOutputStream()}) , and is read by the
* {@link javax.servlet.http.HttpServletRequest#getInputStream()}.
* javax.servlet.http.HttpServletRequest#getInputStream().
* This class omits the default constructor for use by Gson. Instead the user must use
* {@link com.google.gson.webservice.typeadapters.RequestBodyGsonConverter}
*
@ -45,7 +45,12 @@ public final class RequestBody extends ContentBody {
public Builder put(String paramName, Object content, Type typeOfContent) {
return (Builder) super.put(paramName, content, typeOfContent);
}
@Override
public <T> Builder put(TypedKey<T> paramKey, T param) {
return (Builder) super.put(paramKey, param);
}
public RequestBody build() {
return new RequestBody(spec, contents);
}