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

com.jelastic.api.users.response.CollaborationResourceResponses Maven / Gradle / Ivy

There is a newer version: 8.12-1
Show newest version
/*Server class MD5: 08bba5335450b0cbab03ad157beb0f7a*/
package com.jelastic.api.users.response;

import com.jelastic.api.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Collection;
import java.util.HashSet;

/**
 * @name Jelastic API Client
 * @version 8.11.2
 * @copyright Jelastic, Inc.
 */
public class CollaborationResourceResponses extends Response {

    public static final String RESPONSES = "resources";

    private Collection responses;

    public CollaborationResourceResponses() {
        super(OK);
    }

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

    public CollaborationResourceResponses(Collection responses) {
        super(OK);
        this.responses = responses;
    }

    public Collection getResponses() {
        return responses;
    }

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

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

    @Override
    protected CollaborationResourceResponses _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 CollaborationResourceResponse()._fromJSON(response));
            }
        }
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy