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

com.jelastic.api.system.persistence.FileFavorite Maven / Gradle / Ivy

There is a newer version: 8.12-1
Show newest version
package com.jelastic.api.system.persistence;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author Maksym Shevchuk
 */
public class FileFavorite {
    private static final String KEYWORD = "keyword";
    private static final String ID = "id";
    private static final String IS_DIR = "isDir";
    private static final String PATH = "path";
    private static final String FILTER = "filter";

    private Integer id;
    private boolean isDir;
    private String path;
    private String keyword;
    private String filter;

    public FileFavorite() {
    }

    public FileFavorite(Integer id, boolean isDir, String path, String keyword, String filter) {
        this.id = id;
        this.isDir = isDir;
        this.path = path;
        this.keyword = keyword;
        this.filter = filter;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public boolean isDir() {
        return isDir;
    }

    public void setDir(boolean isDir) {
        this.isDir = isDir;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }

    public String getFilter() {
        return filter;
    }

    public void setFilter(String filter) {
        this.filter = filter;
    }

    public JSONObject _toJSON() throws JSONException {
        JSONObject favoriteJSON = new JSONObject();
        favoriteJSON.put(ID, this.id);
        favoriteJSON.put(IS_DIR, this.isDir);
        favoriteJSON.put(PATH, this.path);
        favoriteJSON.put(KEYWORD, this.keyword);
        favoriteJSON.put(FILTER, this.filter);

        return favoriteJSON;
    }

    public FileFavorite _fromJSON(JSONObject jsonObject) throws JSONException {
        if (jsonObject.has(KEYWORD)) {
            this.setKeyword(jsonObject.getString(KEYWORD));
        }

        if (jsonObject.has(PATH)) {
            this.setPath(jsonObject.getString(PATH));
        }

        if (jsonObject.has(ID)) {
            this.setId(jsonObject.getInt(ID));
        }

        if (jsonObject.has(IS_DIR)) {
            this.setDir(jsonObject.getBoolean(IS_DIR));
        }

        if (jsonObject.has(FILTER)) {
            this.setFilter(jsonObject.getString(FILTER));
        }

        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy