1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package nextgrid.api.pom;
19
20 import java.io.Serializable;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.Iterator;
24 import java.util.List;
25
26
27
28
29
30
31 public class QueryProfile implements Serializable {
32
33
34
35
36 private static final long serialVersionUID = 4230594414399444504L;
37
38
39
40
41 private final List<Query> constraints;
42
43
44
45
46 public QueryProfile() {
47 this.constraints = new ArrayList<Query>();
48 }
49
50
51
52
53
54
55 public QueryProfile(List<Query> constraints) {
56 this.constraints = constraints;
57 }
58
59
60
61
62
63
64 public final List<Query> getConstraints() {
65 return Collections.unmodifiableList(this.constraints);
66 }
67
68
69
70
71
72
73 public final void addConstraint(Query query) {
74 if (query != null) {
75 constraints.add(query);
76 }
77 }
78
79
80
81
82
83
84
85 public final void addConstraint(String lang, String text) {
86 if (lang != null && text != null) {
87 constraints.add(new Query(lang, text));
88 }
89 }
90
91
92
93
94
95
96 public final void removeConstraint(String lang) {
97 if (lang != null) {
98 for (Iterator<Query> it = constraints.iterator(); it.hasNext();) {
99 Query q = it.next();
100 if (q.getLang().equals(lang)) {
101 it.remove();
102 return;
103 }
104 }
105 }
106 }
107
108
109
110
111
112
113 public final void removeConstraint(int index) {
114 constraints.remove(index);
115 }
116
117
118
119
120
121
122 public final void removeConstraint(Query q) {
123 if (q != null) {
124 constraints.remove(q);
125 }
126 }
127 }