com.jelastic.api.users.response.CollaborationsResponse Maven / Gradle / Ivy
The newest version!
/*Server class MD5: 6cbc8b5e10032473dbc1609925da4a8a*/
package com.jelastic.api.users.response;
import com.jelastic.api.Response;
import com.jelastic.api.core.persistence.entity.Collaboration;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
/**
* @name Jelastic API Client
* @version 8.11.2
* @copyright Jelastic, Inc.
*/
public class CollaborationsResponse extends Response {
private static final String ARRAY = "array";
private List collaborations;
private Boolean isOwner;
private boolean includeChildren = false;
public CollaborationsResponse() {
super(Response.OK());
}
public CollaborationsResponse(List collaborations, boolean isOwner) {
this();
this.collaborations = collaborations;
this.isOwner = isOwner;
}
public CollaborationsResponse(List collaborations, boolean isOwner, boolean includeChildren) {
this(collaborations, isOwner);
this.includeChildren = includeChildren;
}
public List getCollaborations() {
return collaborations;
}
public void setCollaborations(List collaborations) {
this.collaborations = collaborations;
}
public CollaborationsResponse(int result, String error) {
super(result, error);
}
@Override
public JSONObject _toJSON() throws JSONException {
JSONObject json = super._toJSON();
if (collaborations != null) {
JSONArray jsonArray = new JSONArray();
for (Collaboration collaboration : collaborations) {
jsonArray.put(collaboration.toJSON(isOwner, includeChildren));
}
json.put(ARRAY, jsonArray);
}
return json;
}
@Override
public CollaborationsResponse _fromJSON(JSONObject jsonObject) throws JSONException {
super._fromJSON(jsonObject);
if (jsonObject.has(ARRAY)) {
ArrayList collaborations = new ArrayList<>();
for (int i = 0; i < jsonObject.getJSONArray(ARRAY).length(); i++) {
collaborations.add(new Collaboration().fromJSON(jsonObject.getJSONArray(ARRAY).getJSONObject(i)));
}
this.setCollaborations(collaborations);
}
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy