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

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

The newest version!
/*Server class MD5: aef02f5185717dfe8e055428870fca88*/
package com.jelastic.api.environment.response;

import com.jelastic.api.Response;
import com.jelastic.api.data.po.FileFavorite;
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 FavoriteListResponse extends Response {

    private static final String ARRAY = "array";

    private List favoriteList = new ArrayList<>();

    public FavoriteListResponse(List favoriteList) {
        super(Response.OK);
        this.favoriteList = favoriteList;
    }

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

    public FavoriteListResponse() {
        super(Response.OK);
    }

    public List getFavoriteList() {
        return favoriteList;
    }

    public void setFavoriteList(List favoriteList) {
        this.favoriteList = favoriteList;
    }

    public FavoriteListResponse _fromJSON(JSONObject json) throws JSONException {
        super._fromJSON(json);
        favoriteList = new ArrayList<>();
        if (json.has(ARRAY)) {
            JSONArray arrayJson = json.getJSONArray(ARRAY);
            for (int i = 0; i < arrayJson.length(); i++) {
                favoriteList.add(new FileFavorite()._fromJSON(arrayJson.getJSONObject(i)));
            }
        }
        return this;
    }

    public JSONObject _toJSON() throws JSONException {
        JSONObject json = super._toJSON();
        if (favoriteList != null) {
            JSONArray arrayJson = new JSONArray();
            for (FileFavorite item : favoriteList) {
                arrayJson.put(item._toJSON());
            }
            json.put(ARRAY, arrayJson);
        }
        return json;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy