Skip to content

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