Skip to content

Update the Request object with sensible defaults and access methods #13

Closed
@thinkingserious

Description

@thinkingserious

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions