Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.javabaas.javasdk;
import java.util.*;
/**
* Created by zangyilin on 2017/9/4.
*/
public class JBQueryConditions {
public static final String WHERE = "where";
public static final String LIMIT = "limit";
public static final String SKIP = "skip";
public static final String ORDER = "order";
public static final String INCLUDE = "include";
public static final String KEYS = "keys";
Map> where;
private List include;
private Set selectedKeys;
private int limit;
private int skip = -1;
private LinkedHashMap order;
private Map parameters;
private boolean whereContainsGeo = false;
public JBQueryConditions() {
where = new HashMap<>();
include = new LinkedList<>();
parameters = new HashMap<>();
order = new LinkedHashMap<>();
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public int getSkip() {
return skip;
}
public void setSkip(int skip) {
this.skip = skip;
}
public LinkedHashMap getOrder() {
return order;
}
public void setOrder(LinkedHashMap order) {
this.order = order;
}
public Map> getWhere() {
return where;
}
public void setWhere(Map> where) {
this.where = where;
}
public List getInclude() {
return include;
}
public void setInclude(List include) {
this.include = include;
}
public Set getSelectedKeys() {
return selectedKeys;
}
public void setSelectedKeys(Set selectedKeys) {
this.selectedKeys = selectedKeys;
}
public Map getParameters() {
return parameters;
}
public void setParameters(Map parameters) {
this.parameters = parameters;
}
public void addAscendingOrder(String key) {
order.remove(key);
order.put(key, 1);
}
public void orderByAscending(String key) {
order = new LinkedHashMap<>();
order.put(key, 1);
}
public void orderByGeoPoint() {
whereContainsGeo = true;
}
public void addDescendingOrder(String key) {
order.remove(key);
order.put(key, -1);
}
public void orderByDescending(String key) {
order = new LinkedHashMap<>();
order.put(key, -1);
}
public void include(String key) {
include.add(key);
}
public void selectKeys(Collection keys) {
if (selectedKeys == null) {
selectedKeys = new HashSet<>();
}
selectedKeys.addAll(keys);
}
public Map compileWhereOperationMap() {
Map result = new HashMap<>();
for (Map.Entry> entry : where.entrySet()) {
if (entry.getKey().equals(JBQueryOperation.OR_OP)) {
List