com.jelastic.api.users.response.CollaborationRolesResponse Maven / Gradle / Ivy
The newest version!
/*Server class MD5: db34c2034134d307ad42f1d9fde0d522*/
package com.jelastic.api.users.response;
import com.jelastic.api.Response;
import com.jelastic.api.core.persistence.entity.CollaborationRole;
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 CollaborationRolesResponse extends Response {
private static final String ROLES_KEY = "roles";
private List roles;
public CollaborationRolesResponse() {
super(Response.OK());
}
public CollaborationRolesResponse(List roles) {
this();
this.roles = roles;
}
public List getRoles() {
return roles;
}
public void setRoles(List roles) {
this.roles = roles;
}
public CollaborationRolesResponse(int result, String error) {
super(result, error);
}
@Override
public JSONObject _toJSON() throws JSONException {
JSONObject json = super._toJSON();
if (roles != null) {
JSONArray jsonArray = new JSONArray();
for (CollaborationRole role : roles) {
jsonArray.put(role.toJSON());
}
json.put(ROLES_KEY, jsonArray);
}
return json;
}
@Override
public CollaborationRolesResponse _fromJSON(JSONObject jsonObject) throws JSONException {
super._fromJSON(jsonObject);
if (jsonObject.has(ROLES_KEY)) {
ArrayList roles = new ArrayList<>();
for (int i = 0; i < jsonObject.getJSONArray(ROLES_KEY).length(); i++) {
roles.add(new CollaborationRole().fromJSON(jsonObject.getJSONArray(ROLES_KEY).getJSONObject(i)));
}
this.setRoles(roles);
}
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy