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

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

The newest version!
/*Server class MD5: 04ca8ed58aed1d6a70ac5f90a89055f4*/
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 NodeSSHResponses extends Response {

    public static final String RESPONSES = "responses";

    private Set responses;

    public Set getResponses() {
        return responses;
    }

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

    public NodeSSHResponses() {
        super(OK);
    }

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

    public NodeSSHResponses(Set responses) {
        super(OK);
        this.responses = responses;
    }

    public NodeSSHResponses(NodeSSHResponse response) {
        super(OK);
        this.responses = new HashSet();
        this.responses.add(response);
    }

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy