Update the Request object with sensible defaults and access methods
thinkingserious opened this issue · 3 comments
Issue Summary
In the Request we have:
public Map<String,String> headers;
public Map<String,String> queryParams;set to null when the object gets instantiated.
This could definitely cause JAVA developer errors as they might assume the headers map to be at least instantiated and empty.
In fact in this example:
Map<String,String> requestHeaders = new HashMap<String, String>();
requestHeaders.put("Authorization", "Bearer YOUR_API_KEY");
request.headers = requestHeaders;The user is forced to instantiate a new one and assign it while the developer could simply:
request.headers.put("Authorization","Bearer YOUR_API_KEY");
When playing with beans (such as Request), if you can avoid referencing externally complex objects it is better. In fact, I would suggest you to turn them private (or protected), add getters and setters, initialize them, and even make them final.
Hello, submitted a PR, what I'm not sure about is if we want to make all the variables in the Request class private and have setters and getters. Only updated the maps
Hi @belfazt,
I've added some comments to the PR. Thanks!
I would suggest we make all the variables private and have setters and getters.
Hi @thinkingserious,
I think I got to what you wanted