Skip to content

Package: IdentifiableType

IdentifiableType

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 IdentifiableType represent entity or mapped superclass
23: * types.
24: *
25: * @param <X>
26: * The represented entity or mapped superclass type.
27: */
28: @UnusedJPA
29: public interface IdentifiableType<X> extends ManagedType<X> {
30:         /**
31:          * Return the attribute that corresponds to the id attribute of the entity
32:          * or mapped superclass.
33:          *
34:          * @param type
35:          * the type of the represented id attribute
36:          * @return id attribute
37:          * @throws IllegalArgumentException
38:          * if id attribute of the given type is not present in the
39:          * identifiable type or if the identifiable type has an id class
40:          */
41:         // @Deprecated
42:         // @UnusedJPA
43:         // <Y> SingularAttribute<? super X, Y> getId(Class<Y> type);
44:
45:         /**
46:          * Return the attribute that corresponds to the id attribute declared by the
47:          * entity or mapped superclass.
48:          *
49:          * @param type
50:          * the type of the represented declared id attribute
51:          * @return declared id attribute
52:          * @throws IllegalArgumentException
53:          * if id attribute of the given type is not declared in the
54:          * identifiable type or if the identifiable type has an id class
55:          */
56:         // @Deprecated
57:         // @UnusedJPA
58:         // <Y> SingularAttribute<X, Y> getDeclaredId(Class<Y> type);
59:
60:         /**
61:          * Return the attribute that corresponds to the version attribute of the
62:          * entity or mapped superclass.
63:          *
64:          * @param type
65:          * the type of the represented version attribute
66:          * @return version attribute
67:          * @throws IllegalArgumentException
68:          * if version attribute of the given type is not present in the
69:          * identifiable type
70:          */
71:
72:         <Y> SingularAttribute<? super X, Y> getVersion(Class<Y> type);
73:
74:         /**
75:          * Return the attribute that corresponds to the version attribute declared
76:          * by the entity or mapped superclass.
77:          *
78:          * @param type
79:          * the type of the represented declared version attribute
80:          * @return declared version attribute
81:          * @throws IllegalArgumentException
82:          * if version attribute of the type is not declared in the
83:          * identifiable type
84:          */
85:         <Y> SingularAttribute<X, Y> getDeclaredVersion(Class<Y> type);
86:
87:         /**
88:          * Return the identifiable type that corresponds to the most specific mapped
89:          * superclass or entity extended by the entity or mapped superclass.
90:          *
91:          * @return supertype of identifiable type or null if no
92:          *
93:          * such supertype
94:          */
95:         IdentifiableType<? super X> getSupertype();
96:
97:         /**
98:          * Whether the identifiable type has a single id attribute. Returns true for
99:          * a simple id or embedded id; returns false for an idclass.
100:          *
101:          * @return boolean indicating whether the identifiable
102:          *
103:          * type has a single id attribute
104:          */
105:         boolean hasSingleIdAttribute();
106:
107:         /**
108:          * Whether the identifiable type has a version attribute.
109:          *
110:          * @return boolean indicating whether the identifiable
111:          *
112:          * type has a version attribute
113:          */
114:         boolean hasVersionAttribute();
115:
116:         /**
117:          *
118:          Return the attributes corresponding to the id class of the
119:          *
120:          * identifiable type.
121:          *
122:          * @return id attributes
123:          *
124:          @throws IllegalArgumentException
125:          * if the identifiable type
126:          *
127:          * does not have an id class
128:          */
129:         Set<SingularAttribute<? super X, ?>> getIdClassAttributes();
130:
131:         /**
132:          * Return the type that represents the type of the id.
133:          *
134:          * @return type of id
135:          */
136:         // @Deprecated
137:         // @UnusedJPA
138:         // Type<?> getIdType();
139: }