com.jelastic.api.environment.response.ExtDomainResponses Maven / Gradle / Ivy
The newest version!
/*Server class MD5: bfb8ca32a54b13deda7e35327bc9495c*/
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;
/**
* @name Jelastic API Client
* @version 8.11.2
* @copyright Jelastic, Inc.
*/
public class ExtDomainResponses extends Response {
public static final String EXT_DOMAINS = "extDomains";
private Set extDomains;
public ExtDomainResponses() {
super(OK);
}
public ExtDomainResponses(int result, String error) {
super(result, error);
}
public ExtDomainResponses(Set extDomains) {
super(OK);
this.extDomains = extDomains;
}
public ExtDomainResponses(int result, String error, Set extDomains) {
super(result, error);
this.extDomains = extDomains;
}
@Override
protected JSONObject _toJSON() throws JSONException {
JSONObject json = super._toJSON();
if (extDomains != null) {
JSONArray nodesJson = new JSONArray();
for (ExtDomainResponse response : extDomains) {
nodesJson.put(response.toJSON());
}
json.put(EXT_DOMAINS, nodesJson);
}
return json;
}
@Override
protected ExtDomainResponses _fromJSON(JSONObject json) throws JSONException {
super._fromJSON(json);
JSONArray nodesJson = json.optJSONArray(EXT_DOMAINS);
if (nodesJson != null) {
extDomains = new HashSet<>();
for (int i = 0; i < nodesJson.length(); i++) {
JSONObject response = nodesJson.getJSONObject(i);
extDomains.add(new ExtDomainResponse().fromJSON(response));
}
}
return this;
}
public Set getExtDomains() {
return extDomains;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy