Skip to contentPackage: ManagedType
ManagedType
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.metamodel;
16:
17: import java.util.Set;
18:
19: import cz.cvut.kbss.jopa.UnusedJPA;
20:
21: /**
22: * Instances of the type ManagedType represent entity, mapped superclass, and
23: * embeddable types.
24: *
25: * @param <X>
26: * The represented type.
27: */
28: @UnusedJPA
29: public interface ManagedType<X> extends Type<X> {
30:         /**
31:          * Return the attributes of the managed type.
32:          *
33:          * @return attributes of the managed type
34:          */
35:         Set<Attribute<? super X, ?>> getAttributes();
36:
37:         /**
38:          * Return the attributes declared by the managed type. Returns empty set if
39:          * the managed type has no declared attributes.
40:          *
41:          * @return declared attributes of the managed type
42:          */
43:         Set<Attribute<X, ?>> getDeclaredAttributes();
44:
45:         /**
46:          * Return the single-valued attribute of the managed type that corresponds
47:          * to the specified name and Java type.
48:          *
49:          * @param name
50:          * the name of the represented attribute
51:          *@param type
52:          * the type of the represented attribute
53:          *@return single-valued attribute with given name and type
54:          *@throws IllegalArgumentException
55:          * if attribute of the given name and type is not present in the
56:          * managed type
57:          */
58:         <Y> SingularAttribute<? super X, Y> getSingularAttribute(String name,
59:                         Class<Y> type);
60:
61:         /**
62:          * Return the single-valued attribute declared by the managed type that
63:          * corresponds to the specified name and Java type.
64:          *
65:          * @param name
66:          * the name of the represented attribute
67:          * @param type
68:          * the type of the represented attribute
69:          * @return declared single-valued attribute of the given name and type
70:          * @throws IllegalArgumentException
71:          * if attribute of the given name and type is not declared in
72:          * the managed type
73:          * */
74:         <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(String name,
75:                         Class<Y> type);
76:
77:         /**
78:          * Return the single-valued attributes of the managed type. Returns empty
79:          * set if the managed type has no single-valued attributes.
80:          *
81:          * @return single-valued attributes
82:          */
83:         Set<SingularAttribute<? super X, ?>> getSingularAttributes();
84:
85:         /**
86:          * Return the single-valued attributes declared by the managed type. Returns
87:          * empty set if the managed type has no declared single-valued attributes.
88:          *
89:          * @return declared single-valued attributes
90:          */
91:         Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes();
92:
93:         /**
94:          * Return the Collection-valued attribute of the managed type that
95:          * corresponds to the specified name and Java element type.
96:          *
97:          * @param name
98:          * the name of the represented attribute
99:          *@param elementType
100:          * the element type of the represented attribute
101:          * @return CollectionAttribute of the given name and element type
102:          * @throws IllegalArgumentException
103:          * if attribute of the given name and type is not present in the
104:          * managed type
105:          */
106:         <E> CollectionAttribute<? super X, E> getCollection(String name,
107:                         Class<E> elementType);
108:
109:         /**
110:          * Return the Collection-valued attribute declared by the managed type that
111:          * corresponds to the specified name and Java element type.
112:          *
113:          * @param name
114:          * the name of the represented attribute
115:          * @param elementType
116:          * the element type of the represented attribute
117:          * @return declared CollectionAttribute of the given name and element type
118:          * @throws IllegalArgumentException
119:          * if attribute of the given name and type is not declared in
120:          * the managed type
121:          */
122:         <E> CollectionAttribute<X, E> getDeclaredCollection(String name,
123:                         Class<E> elementType);
124:
125:         /**
126:          * Return the Set-valued attribute of the managed type that corresponds to
127:          * the specified name and Java element type.
128:          *
129:          * @param name
130:          * the name of the represented attribute
131:          * @param elementType
132:          * the element type of the represented attribute
133:          * @return SetAttribute of the given name and element type
134:          * @throws IllegalArgumentException
135:          * if attribute of the given name and type is not present in the
136:          * managed type
137:          **/
138:         <E> SetAttribute<? super X, E> getSet(String name, Class<E> elementType);
139:
140:         /**
141:          * Return the Set-valued attribute declared by the managed type that
142:          * corresponds to the specified name and Java element type.
143:          *
144:          * @param name
145:          * the name of the represented attribute
146:          * @param elementType
147:          * the element type of the represented attribute
148:          * @return declared SetAttribute of the given name and element type
149:          * @throws IllegalArgumentException
150:          * if attribute of the given name and type is not declared in
151:          * the managed type
152:          */
153:
154:         <E> SetAttribute<X, E> getDeclaredSet(String name, Class<E> elementType);
155:
156:         /**
157:          * Return the List-valued attribute of the managed type that corresponds to
158:          * the specified name and Java element type.
159:          *
160:          * @param name
161:          * the name of the represented attribute
162:          * @param elementType
163:          * the element type of the represented attribute
164:          * @return ListAttribute of the given name and element type
165:          * @throws IllegalArgumentException
166:          * if attribute of the given name and type is not present in the
167:          * managed type
168:          */
169:         <E> ListAttribute<? super X, E> getList(String name, Class<E> elementType);
170:
171:         /**
172:          * Return the List-valued attribute declared by the managed type that
173:          * corresponds to the specified name and Java element type.
174:          *
175:          * @param name
176:          * the name of the represented attribute
177:          * @param elementType
178:          * the element type of the represented attribute
179:          * @return declared ListAttribute of the given name and element type
180:          * @throws IllegalArgumentException
181:          * if attribute of the given name and type is not declared in
182:          * the managed type
183:          */
184:         <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
185:
186:         /**
187:          * Return the Map-valued attribute of the managed type that corresponds to
188:          * the specified name and Java key and value types.
189:          *
190:          * @param name
191:          * the name of the represented attribute
192:          * @param keyType
193:          * the key type of the represented attribute
194:          * @param valueType
195:          * the value type of the represented attribute
196:          * @return MapAttribute of the given name and key and value types
197:          * @throws IllegalArgumentException
198:          * if attribute of the given name and type is not present in the
199:          * managed type
200:          */
201:         <K, V> MapAttribute<? super X, K, V> getMap(String name, Class<K> keyType,
202:                         Class<V> valueType);
203:
204:         /**
205:          * Return the Map-valued attribute declared by the managed type that
206:          * corresponds to the specified name and Java key and value types.
207:          *
208:          * @param name
209:          * the name of the represented attribute
210:          * @param keyType
211:          * the key type of the represented attribute
212:          * @param valueType
213:          * the value type of the represented attribute
214:          * @return declared MapAttribute of the given name and key and value types
215:          * @throws IllegalArgumentException
216:          * if attribute of the given name and type is not declared in
217:          * the managed type
218:          */
219:         <K, V> MapAttribute<X, K, V> getDeclaredMap(String name, Class<K> keyType,
220:                         Class<V> valueType);
221:
222:         /**
223:          * Return all multi-valued attributes (Collection-, Set-, List-, and
224:          * Map-valued attributes) of the managed type. Returns empty set if the
225:          * managed type has no multi-valued attributes.
226:          *
227:          * @return Collection-, Set-, List-, and Map-valued attributes
228:          */
229:         Set<PluralAttribute<? super X, ?, ?>> getPluralAttributes();
230:
231:         /**
232:          * Return all multi-valued attributes (Collection-, Set-, List-, and
233:          * Map-valued attributes) declared by the managed type. Returns empty set if
234:          * the managed type has no declared multi-valued attributes.
235:          *
236:          * @return declared Collection-, Set-, List-, and Map-valued
237:          *
238:          * attributes
239:          */
240:         Set<PluralAttribute<X, ?, ?>> getDeclaredPluralAttributes();
241:
242:         // String-based:
243:         /**
244:          * Return the attribute of the managed type that corresponds to the
245:          * specified name.
246:          *
247:          * @param name
248:          * the name of the represented attribute
249:          * @return attribute with given name
250:          * @throws IllegalArgumentException
251:          * if attribute of the given
252:          *
253:          * name is not present in the managed type
254:          */
255:         Attribute<? super X, ?> getAttribute(String name);
256:
257:         /**
258:          * Return the attribute declared by the managed type that corresponds to the
259:          * specified name.
260:          *
261:          * @param name
262:          * the name of the represented attribute
263:          * @return attribute with given name
264:          * @throws IllegalArgumentException
265:          * if attribute of the given
266:          *
267:          * name is not declared in the managed type
268:          */
269:         Attribute<X, ?> getDeclaredAttribute(String name);
270:
271:         /**
272:          * Return the single-valued attribute of the managed type that corresponds
273:          * to the specified name.
274:          *
275:          * @param name
276:          * the name of the represented attribute
277:          * @return single-valued attribute with the given name
278:          * @throws IllegalArgumentException
279:          * if attribute of the given
280:          *
281:          * name is not present in the managed type
282:          */
283:         SingularAttribute<? super X, ?> getSingularAttribute(String name);
284:
285:         /**
286:          * Return the single-valued attribute declared by the managed type that
287:          * corresponds to the specified name.
288:          *
289:          * @param name
290:          * the name of the represented attribute
291:          * @return declared single-valued attribute of the given
292:          *
293:          * name
294:          * @throws IllegalArgumentException
295:          * if attribute of the given
296:          *
297:          * name is not declared in the managed type
298:          */
299:         SingularAttribute<X, ?> getDeclaredSingularAttribute(String name);
300:
301:         /**
302:          * Return the Collection-valued attribute of the managed type that
303:          * corresponds to the specified name.
304:          *
305:          * @param name
306:          * the name of the represented attribute
307:          * @return CollectionAttribute of the given name
308:          * @throws IllegalArgumentException
309:          * if attribute of the given
310:          *
311:          * name is not present in the managed type
312:          */
313:         CollectionAttribute<? super X, ?> getCollection(String name);
314:
315:         /**
316:          * Return the Collection-valued attribute declared by the managed type that
317:          * corresponds to the specified name.
318:          *
319:          * @param name
320:          * the name of the represented attribute
321:          * @return declared CollectionAttribute of the given name
322:          * @throws IllegalArgumentException
323:          * if attribute of the given
324:          *
325:          * name is not declared in the managed type
326:          */
327:         CollectionAttribute<X, ?> getDeclaredCollection(String name);
328:
329:         /**
330:          * Return the Set-valued attribute of the managed type that corresponds to
331:          * the specified name.
332:          *
333:          * @param name
334:          * the name of the represented attribute
335:          * @return SetAttribute of the given name
336:          * @throws IllegalArgumentException
337:          * if attribute of the given
338:          *
339:          * name is not present in the managed type
340:          */
341:         SetAttribute<? super X, ?> getSet(String name);
342:
343:         /**
344:          * Return the Set-valued attribute declared by the managed type that
345:          * corresponds to the specified name.
346:          *
347:          * @param name
348:          * the name of the represented attribute
349:          * @return declared SetAttribute of the given name
350:          * @throws IllegalArgumentException
351:          * if attribute of the given
352:          *
353:          * name is not declared in the managed type
354:          */
355:         SetAttribute<X, ?> getDeclaredSet(String name);
356:
357:         /**
358:          * Return the List-valued attribute of the managed type that corresponds to
359:          * the specified name.
360:          *
361:          * @param name
362:          * the name of the represented attribute
363:          * @return ListAttribute of the given name
364:          * @throws IllegalArgumentException
365:          * if attribute of the given
366:          *
367:          * name is not present in the managed type
368:          */
369:         ListAttribute<? super X, ?> getList(String name);
370:
371:         /**
372:          * Return the List-valued attribute declared by the managed type that
373:          * corresponds to the specified name.
374:          *
375:          * @param name
376:          * the name of the represented attribute
377:          * @return declared ListAttribute of the given name
378:          * @throws IllegalArgumentException
379:          * if attribute of the given
380:          *
381:          * name is not declared in the managed type
382:          */
383:         ListAttribute<X, ?> getDeclaredList(String name);
384:
385:         /**
386:          * Return the Map-valued attribute of the managed type that corresponds to
387:          * the specified name.
388:          *
389:          * @param name
390:          * the name of the represented attribute
391:          * @return MapAttribute of the given name
392:          * @throws IllegalArgumentException
393:          * if attribute of the given
394:          *
395:          * name is not present in the managed type
396:          */
397:         MapAttribute<? super X, ?, ?> getMap(String name);
398:
399:         /**
400:          * Return the Map-valued attribute declared by the managed type that
401:          * corresponds to the specified name.
402:          *
403:          * @param name
404:          * the name of the represented attribute
405:          * @return declared MapAttribute of the given name
406:          * @throws IllegalArgumentException
407:          * if attribute of the given
408:          *
409:          * name is not declared in the managed type
410:          */
411:         MapAttribute<X, ?, ?> getDeclaredMap(String name);
412: }