01: package org.osbl.persistence;
02:
03: import java.util.*;
04:
05: public abstract class SimpleQueryCommand<T> extends QueryCommand<T> {
06: protected List<Filter> filters = new LinkedList<Filter>();
07: protected Map<String, Sort> sorts = new LinkedHashMap<String, Sort>();
08: protected Map<String, Fetch> fetches = new LinkedHashMap<String, Fetch>();
09:
10: public SimpleQueryCommand<T> addFilter(String property,
11: Operator operator, Object value) {
12: filters.add(new Filter(property, operator, value));
13: return this ;
14: }
15:
16: public void clearFilters() {
17: filters.clear();
18: }
19:
20: public SimpleQueryCommand<T> addSort(String property, Sort order) {
21: sorts.put(property, order);
22: return this ;
23: }
24:
25: public void clearSorts() {
26: sorts.clear();
27: }
28:
29: public SimpleQueryCommand<T> addFetch(String property, Fetch fetch) {
30: fetches.put(property, fetch);
31: return this ;
32: }
33:
34: public void clearFetchs() {
35: fetches.clear();
36: }
37:
38: protected static class Filter {
39: String property;
40: Operator operator;
41: Object value;
42:
43: public Filter(String property, Operator operator, Object value) {
44: this .property = property;
45: this .operator = operator;
46: this .value = value;
47: }
48:
49: public String getProperty() {
50: return property;
51: }
52:
53: public Operator getOperator() {
54: return operator;
55: }
56:
57: public Object getValue() {
58: return value;
59: }
60: }
61: }
|