Skip to content

Package: IdentifiableType

IdentifiableType

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: import cz.cvut.kbss.jopa.UnusedJPA;
19:
20: /**
21: * Instances of the type IdentifiableType represent entity or mapped superclass
22: * types.
23: *
24: * @param <X>
25: * The represented entity or mapped superclass type.
26: */
27: @UnusedJPA
28: public interface IdentifiableType<X> extends ManagedType<X> {
29:
30: /**
31: * Return the attribute that corresponds to the version attribute of the
32: * entity or mapped superclass.
33: *
34: * @param type
35: * the type of the represented version attribute
36: * @return version attribute
37: * @throws IllegalArgumentException
38: * if version attribute of the given type is not present in the
39: * identifiable type
40: */
41:
42: <Y> SingularAttribute<? super X, Y> getVersion(Class<Y> type);
43:
44: /**
45: * Return the attribute that corresponds to the version attribute declared
46: * by the entity or mapped superclass.
47: *
48: * @param type
49: * the type of the represented declared version attribute
50: * @return declared version attribute
51: * @throws IllegalArgumentException
52: * if version attribute of the type is not declared in the
53: * identifiable type
54: */
55: <Y> SingularAttribute<X, Y> getDeclaredVersion(Class<Y> type);
56:
57: /**
58: * Return the identifiable type that corresponds to the most specific mapped
59: * superclass or entity extended by the entity or mapped superclass.
60: *
61: * @return supertype of identifiable type or null if no
62: *
63: * such supertype
64: */
65: IdentifiableType<? super X> getSupertype();
66:
67: /**
68: * Whether the identifiable type has a single id attribute. Returns true for
69: * a simple id or embedded id; returns false for an idclass.
70: *
71: * @return boolean indicating whether the identifiable
72: *
73: * type has a single id attribute
74: */
75: boolean hasSingleIdAttribute();
76:
77: /**
78: * Whether the identifiable type has a version attribute.
79: *
80: * @return boolean indicating whether the identifiable
81: *
82: * type has a version attribute
83: */
84: boolean hasVersionAttribute();
85:
86: /**
87: * Return the attribute that corresponds to the id attribute of the entity or mapped superclass.
88: * @return Identifier attribute
89: */
90: @NonJPA
91: Identifier<? super X, ?> getIdentifier();
92: }