Created
February 3, 2013 08:07
-
-
Save zaur/4700920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Request { | |
private String id = "null"; | |
private String method = ""; | |
private RequestParams params = new RequestParams(); | |
public String getId() { | |
return id; | |
} | |
public String getMethod() { | |
return method; | |
} | |
public Request setId(String id) { | |
this.id = id; | |
return this; | |
} | |
public Request setMethod(String method) { | |
this.method = method; | |
return this; | |
} | |
public Request addParam(String paramName, String value) { | |
params.put(paramName, value); | |
return this; | |
} | |
public Request addParam(String param, Object object) { | |
params.put(param, object); | |
return this; | |
} | |
public String toJson() { | |
ObjectMapper objectMapper = new ObjectMapper(); | |
try { | |
return objectMapper.writeValueAsString(this); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
Log.e("JSON_GEN", e.getMessage()); | |
} | |
return ""; | |
} | |
private class RequestParams { | |
private Map<String, Object> params = new HashMap<String, Object>(); | |
public void put(String paramName, Object object) { | |
params.put(paramName, object); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment