All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jelastic.api.environment.response.EnvironmentInfoResponses Maven / Gradle / Ivy

There is a newer version: 8.12-1
Show newest version
/*Server class MD5: 3590a35857fb349fe6a3f78b6792149a*/
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 EnvironmentInfoResponses extends Response {

    public static final String INFOS = "infos";

    private Set infos;

    public EnvironmentInfoResponses() {
        super(OK);
    }

    public EnvironmentInfoResponses(int result, String error) {
        super(result, error);
    }

    public EnvironmentInfoResponses(Set infos) {
        super(OK);
        this.infos = infos;
    }

    public Set getResponses() {
        return infos;
    }

    public void setResponses(Set infos) {
        this.infos = infos;
    }

    @Override
    protected JSONObject _toJSON() throws JSONException {
        JSONObject json = super._toJSON();
        if (infos != null) {
            JSONArray nodesJson = new JSONArray();
            for (EnvironmentInfoResponse response : infos) {
                nodesJson.put(response._toJSON());
            }
            json.put(INFOS, nodesJson);
        }
        return json;
    }

    @Override
    protected EnvironmentInfoResponses _fromJSON(JSONObject json) throws JSONException {
        super._fromJSON(json);
        JSONArray nodesJson = json.optJSONArray(INFOS);
        if (nodesJson != null) {
            infos = new HashSet();
            for (int i = 0; i < nodesJson.length(); i++) {
                JSONObject response = nodesJson.getJSONObject(i);
                infos.add(new EnvironmentInfoResponse()._fromJSON(response));
            }
        }
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy