com.jelastic.api.data.po.FileFavorite Maven / Gradle / Ivy
The newest version!
/*Server class MD5: 7c4063b098fc4bc3a7ab0d01fa20e083*/
package com.jelastic.api.data.po;
import com.jelastic.api.system.persistence.FileFilter;
import com.jelastic.api.system.persistence.FilePermissions;
import org.json.JSONException;
import org.json.JSONObject;
/**
* @name Jelastic API Client
* @version 8.11.2
* @copyright Jelastic, Inc.
*/
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(FilePermissions filePermission) {
this.id = filePermission.getId();
this.isDir = filePermission.isDir();
this.path = filePermission.getFilePath();
this.keyword = filePermission.getKeyword();
if (!filePermission.getFilters().isEmpty()) {
FileFilter fileFilter = filePermission.getFilters().iterator().next();
this.filter = fileFilter.getPattern();
} else {
filter = ".*";
}
}
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