Skip to content

Package: ManagedType

ManagedType

Coverage

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