Added a precondition check to ensure that a parameter being added to a ParamMap is compatible with its spec.

Added comments in RequestBody and ResponseBody to indicate that their Gson type adapters must be used.
This commit is contained in:
Inderjeet Singh 2010-01-20 13:52:22 +00:00
parent 51efca8457
commit e5c89f1ebc
3 changed files with 6 additions and 3 deletions

View File

@ -41,7 +41,7 @@ class ParamMap {
}
public Builder<T> put(String paramName, Object content, Type typeOfContent) {
spec.checkIfCompatible(paramName, typeOfContent);
Preconditions.checkArgument(spec.checkIfCompatible(paramName, typeOfContent));
contents.put(paramName, content);
return this;
}

View File

@ -23,6 +23,8 @@ import java.util.Map;
* 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()}.
* This class omits the default constructor for use by Gson. Instead the user must use
* {@link com.google.gson.webservice.typeadapters.RequestBodyGsonConverter}
*
* @author inder
*/

View File

@ -20,7 +20,9 @@ import java.util.Map;
/**
* body of the response. This is written out as JSON to be sent out to the client.
*
* This class omits the default constructor for use by Gson. Instead the user must use
* {@link com.google.gson.webservice.typeadapters.ResponseBodyGsonConverter}
*
* @author inder
*/
public final class ResponseBody extends ContentBody {
@ -46,7 +48,6 @@ public final class ResponseBody extends ContentBody {
}
}
private ResponseBody(ResponseBodySpec spec, Map<String, Object> contents) {
super(spec, contents);
}