Skip to content

Package: From

From

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.model.query.criteria;
16:
17: import java.util.Set;
18:
19: import cz.cvut.kbss.jopa.model.metamodel.CollectionAttribute;
20: import cz.cvut.kbss.jopa.model.metamodel.ListAttribute;
21: import cz.cvut.kbss.jopa.model.metamodel.MapAttribute;
22: import cz.cvut.kbss.jopa.model.metamodel.SetAttribute;
23: import cz.cvut.kbss.jopa.model.metamodel.SingularAttribute;
24:
25: /**
26: * Represents a bound type, usually an entity that appears in the from clause,
27: * but may also be an embeddable belonging to an entity in the from clause.
28: * Serves as a factory for Joins of associations, embeddables, and collections
29: * belonging to the type, and for Paths of attributes belonging to the type.
30: *
31: * @param <Z>
32: * the source type
33: * @param <X>
34: * the target type
35: */
36: public interface From<Z, X> extends Path<X>, FetchParent<Z, X> {
37:         /**
38:          * Return the joins that have been made from this bound type. Returns empty
39:          * set if no joins have been made from this bound type. Modifications to the
40:          * set do not affect the query.
41:          *
42:          * @return joins made from this type
43:          */
44:         Set<Join<X, ?>> getJoins();
45:
46:         /**
47:          * Whether the From object has been obtained as a result of correlation (use
48:          * of a Subquery correlate method).
49:          *
50:          * @return boolean indicating whether the object has been
51:          *
52:          * obtained through correlation
53:          */
54:         boolean isCorrelated();
55:
56:         /**
57:          * Returns the parent From object from which the correlated From object has
58:          * been obtained through correlation (use of a Subquery correlate method).
59:          *
60:          * @return the parent of the correlated From object
61:          * @throws IllegalStateException
62:          * if the From object has
63:          *
64:          * not been obtained through correlation
65:          */
66:         From<Z, X> getCorrelationParent();
67:
68:         /**
69:          * Create an inner join to the specified single-valued attribute.
70:          *
71:          * @param attribute
72:          * target of the join
73:          * @return the resulting join
74:          **/
75:         <Y> Join<X, Y> join(SingularAttribute<? super X, Y> attribute);
76:
77:         /**
78:          * /** Create a join to the specified single-valued attribute using the
79:          * given join type.
80:          *
81:          * @param attribute
82:          * target of the join
83:          * @param jt
84:          * join type
85:          * @return the resulting join
86:          **/
87:         <Y> Join<X, Y> join(SingularAttribute<? super X, Y> attribute, JoinType jt);
88:
89:         /**
90:          * Create an inner join to the specified Collection-valued attribute.
91:          *
92:          * @param collection
93:          * target of the join
94:          * @return the resulting join
95:          **/
96:         <Y> CollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection);
97:
98:         /**
99:          * Create an inner join to the specified Set-valued attribute.
100:          *
101:          * @param set
102:          * target of the join
103:          * @return the resulting join
104:          **/
105:         <Y> SetJoin<X, Y> join(SetAttribute<? super X, Y> set);
106:
107:         /**
108:          * Create an inner join to the specified List-valued attribute.
109:          *
110:          * @param list
111:          * target of the join
112:          * @return the resulting join
113:          **/
114:         <Y> ListJoin<X, Y> join(ListAttribute<? super X, Y> list);
115:
116:         /**
117:          * Create an inner join to the specified Map-valued attribute.
118:          *
119:          * @param map
120:          * target of the join
121:          * @return the resulting join
122:          **/
123:         <K, V> MapJoin<X, K, V> join(MapAttribute<? super X, K, V> map);
124:
125:         /**
126:          * Create a join to the specified Collection-valued attribute using the
127:          * given join type.
128:          *
129:          * @param collection
130:          * target of the join
131:          * @param jt
132:          * join type
133:          * @return the resulting join
134:          **/
135:         <Y> CollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection,
136:                         JoinType jt);
137:
138:         /**
139:          * Create a join to the specified Set-valued attribute using the given join
140:          * type.
141:          *
142:          * @param set
143:          * target of the join
144:          * @param jt
145:          * join type
146:          * @return the resulting join
147:          **/
148:         <Y> SetJoin<X, Y> join(SetAttribute<? super X, Y> set, JoinType jt);
149:
150:         /**
151:          * Create a join to the specified List-valued attribute using the given join
152:          * type.
153:          *
154:          * @param list
155:          * target of the join
156:          * @param jt
157:          * join type
158:          * @return the resulting join
159:          **/
160:         <Y> ListJoin<X, Y> join(ListAttribute<? super X, Y> list, JoinType jt);
161:
162:         /**
163:          * Create a join to the specified Map-valued attribute using the given join
164:          * type.
165:          *
166:          * @param map
167:          * target of the join
168:          * @param jt
169:          * join type
170:          * @return the resulting join
171:          **/
172:         <K, V> MapJoin<X, K, V> join(MapAttribute<? super X, K, V> map, JoinType jt);
173:
174:         // String-based:
175:         /**
176:          * Create an inner join to the specified attribute.
177:          *
178:          * @param attributeName
179:          * name of the attribute for the target of the join
180:          * @return the resulting join
181:          * @throws IllegalArgumentException
182:          * if attribute of the given name does not exist
183:          **/
184:         <Y> Join<X, Y> join(String attributeName);
185:
186:         /**
187:          * Create an inner join to the specified Collection-valued attribute.
188:          *
189:          * @param attributeName
190:          * name of the attribute for the target of the join
191:          * @return the resulting join
192:          * @throws IllegalArgumentException
193:          * if attribute of the given name does not exist
194:          **/
195:         <Y> CollectionJoin<X, Y> joinCollection(String attributeName);
196:
197:         /**
198:          * Create an inner join to the specified Set-valued attribute.
199:          *
200:          * @param attributeName
201:          * name of the attribute for the target of the join
202:          * @return the resulting join
203:          * @throws IllegalArgumentException
204:          * if attribute of the given name does not exist
205:          **/
206:         <Y> SetJoin<X, Y> joinSet(String attributeName);
207:
208:         /**
209:          * Create an inner join to the specified List-valued attribute.
210:          *
211:          * @param attributeName
212:          * name of the attribute for the target of the join
213:          * @return the resulting join
214:          * @throws IllegalArgumentException
215:          * if attribute of the given name does not exist
216:          **/
217:         <Y> ListJoin<X, Y> joinList(String attributeName);
218:
219:         /**
220:          * Create an inner join to the specified Map-valued attribute.
221:          *
222:          * @param attributeName
223:          * name of the attribute for the target of the join
224:          * @return the resulting join
225:          * @throws IllegalArgumentException
226:          * if attribute of the given name does not exist
227:          **/
228:         <K, V> MapJoin<X, K, V> joinMap(String attributeName);
229:
230:         /**
231:          * Create a join to the specified attribute using the given join type.
232:          *
233:          * @param attributeName
234:          * name of the attribute for the target of the join
235:          * @param jt
236:          * join type
237:          * @return the resulting join
238:          * @throws IllegalArgumentException
239:          * if attribute of the given name does not exist
240:          **/
241:         <Y> Join<X, Y> join(String attributeName, JoinType jt);
242:
243:         /**
244:          * Create a join to the specified Collection-valued attribute using the
245:          * given join type.
246:          *
247:          * @param attributeName
248:          * name of the attribute for the target of the join
249:          * @param jt
250:          * join type
251:          * @return the resulting join
252:          * @throws IllegalArgumentException
253:          * if attribute of the given name does not exist
254:          **/
255:         <Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt);
256:
257:         /**
258:          * Create a join to the specified Set-valued attribute using the given join
259:          * type.
260:          *
261:          * @param attributeName
262:          * name of the attribute for the target of the join
263:          * @param jt
264:          * join type
265:          * @return the resulting join
266:          * @throws IllegalArgumentException
267:          * if attribute of the given name does not exist
268:          **/
269:         <Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt);
270:
271:         /**
272:          * Create a join to the specified List-valued attribute using the given join
273:          * type.
274:          *
275:          * @param attributeName
276:          * name of the attribute for the target of the join
277:          * @param jt
278:          * join type
279:          * @return the resulting join
280:          * @throws IllegalArgumentException
281:          * if attribute of the given name does not exist
282:          **/
283:         <Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt);
284:
285:         /**
286:          * Create a join to the specified Map-valued attribute using the given join
287:          * type.
288:          *
289:          * @param attributeName
290:          * name of the attribute for the target of the join
291:          * @param jt
292:          * join type
293:          * @return the resulting join
294:          * @throws IllegalArgumentException
295:          * if attribute of the given name does not exist
296:          **/
297:         <K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt);
298:
299: }