![JAR search and dependency download from the Maven repository](/logo.png)
com.jelastic.api.environment.response.Responses Maven / Gradle / Ivy
The newest version!
package com.jelastic.api.environment.response;
import com.jelastic.api.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashSet;
import java.util.Set;
public class Responses extends Response {
private Set responses;
public Responses() {
super(OK);
}
public Responses(int result, String error) {
super(result, error);
}
public Responses(Set responses) {
super(OK);
this.responses = responses;
}
public Responses(int result, String error, Set responses) {
super(result, error);
this.responses = responses;
}
public Set getResponses() {
return responses;
}
public void setResponses(Set responses) {
this.responses = responses;
}
@Override
protected JSONObject _toJSON() throws JSONException {
JSONObject json = super._toJSON();
if (responses != null) {
JSONArray nodesJson = new JSONArray();
for (Response response : responses) {
nodesJson.put(response.toJSON());
}
json.put("infos", nodesJson);
}
return json;
}
@Override
protected Responses _fromJSON(JSONObject json) throws JSONException {
super._fromJSON(json);
JSONArray nodesJson = json.optJSONArray("infos");
if (nodesJson != null) {
responses = new HashSet<>();
for (int i = 0; i < nodesJson.length(); i++) {
JSONObject response = nodesJson.getJSONObject(i);
responses.add(new Response().fromJSON(response));
}
}
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy