Skip to content

Commit

Permalink
added 2 new constructors to json response
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonUden committed Jan 6, 2024
1 parent 9c76d29 commit 7bdbb94
Showing 1 changed file with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* A response containing a {@link JSONObject} or {@link JSONArray}
*
*
* @author Zeeraa
*/
public class JSONResponse extends AbstractHTTPResponse {
Expand All @@ -20,10 +20,28 @@ public class JSONResponse extends AbstractHTTPResponse {
private final int indentation;

/* ---- JSONObject ---- */
/**
* Sends an empty {@link JSONObject} with the default repose code of
* {@link HTTPResponseCode#OK} and no indentation
*/
public JSONResponse() {
this(new JSONObject(), HTTPResponseCode.OK, 0);
}

/**
* Sends an empty {@link JSONObject} with the provided response code and no indentation
*
* @param code The {@link HTTPResponseCode}
*/
public JSONResponse(HTTPResponseCode code) {
this(new JSONObject(), code, 0);
}


/**
* Sends a {@link JSONObject} with the default repose code of
* {@link HTTPResponseCode#OK} and no indentation
*
*
* @param json The {@link JSONObject} to send
*/
public JSONResponse(JSONObject json) {
Expand All @@ -32,7 +50,7 @@ public JSONResponse(JSONObject json) {

/**
* Sends a {@link JSONObject} with the provided response code and no indentation
*
*
* @param json The {@link JSONObject} to send
* @param code The {@link HTTPResponseCode}
*/
Expand All @@ -42,7 +60,7 @@ public JSONResponse(JSONObject json, HTTPResponseCode code) {

/**
* Sends a {@link JSONObject} with the provided response code and indentation
*
*
* @param json The {@link JSONObject} to send
* @param code The {@link HTTPResponseCode}
* @param indentation The indentation to use
Expand All @@ -53,7 +71,7 @@ public JSONResponse(JSONObject json, HTTPResponseCode code, int indentation) {

/**
* Sends a {@link JSONObject} with the provided response code and no indentation
*
*
* @param json The {@link JSONObject} to send
* @param code The http response code
*/
Expand All @@ -63,7 +81,7 @@ public JSONResponse(JSONObject json, int code) {

/**
* Sends a {@link JSONObject} with the provided response code and indentation
*
*
* @param json The {@link JSONObject} to send
* @param code The http response code
* @param indentation The indentation to use
Expand All @@ -76,7 +94,7 @@ public JSONResponse(JSONObject json, int code, int indentation) {
/**
* Sends a {@link JSONArray} with the default repose code of
* {@link HTTPResponseCode#OK} and no indentation
*
*
* @param json The {@link JSONArray} to send
*/
public JSONResponse(JSONArray json) {
Expand All @@ -85,7 +103,7 @@ public JSONResponse(JSONArray json) {

/**
* Sends a {@link JSONArray} with the provided response code and no indentation
*
*
* @param json The {@link JSONArray} to send
* @param code The {@link HTTPResponseCode}
*/
Expand All @@ -95,7 +113,7 @@ public JSONResponse(JSONArray json, HTTPResponseCode code) {

/**
* Sends a {@link JSONArray} with the provided response code and indentation
*
*
* @param json The {@link JSONArray} to send
* @param code The {@link HTTPResponseCode}
* @param indentation The indentation to use
Expand All @@ -106,7 +124,7 @@ public JSONResponse(JSONArray json, HTTPResponseCode code, int indentation) {

/**
* Sends a {@link JSONArray} with the provided response code and no indentation
*
*
* @param json The {@link JSONArray} to send
* @param code The http response code
*/
Expand All @@ -116,7 +134,7 @@ public JSONResponse(JSONArray json, int code) {

/**
* Sends a {@link JSONArray} with the provided response code and indentation
*
*
* @param json The {@link JSONArray} to send
* @param code The http response code
* @param indentation The indentation to use
Expand Down

0 comments on commit 7bdbb94

Please sign in to comment.