Skip to content

Package: IdentifiableType

IdentifiableType

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.model.metamodel;
19:
20: import cz.cvut.kbss.jopa.NonJPA;
21:
22: import java.util.Set;
23:
24: /**
25: * Instances of the type IdentifiableType represent entity or mapped superclass
26: * types.
27: *
28: * @param <X>
29: * The represented entity or mapped superclass type.
30: */
31: public interface IdentifiableType<X> extends ManagedType<X> {
32:
33: /**
34: * Return the attribute that corresponds to the version attribute of the
35: * entity or mapped superclass.
36: *
37: * @param type
38: * the type of the represented version attribute
39: * @return version attribute
40: * @throws IllegalArgumentException
41: * if version attribute of the given type is not present in the
42: * identifiable type
43: */
44:
45: <Y> SingularAttribute<? super X, Y> getVersion(Class<Y> type);
46:
47: /**
48: * Return the attribute that corresponds to the version attribute declared
49: * by the entity or mapped superclass.
50: *
51: * @param type
52: * the type of the represented declared version attribute
53: * @return declared version attribute
54: * @throws IllegalArgumentException
55: * if version attribute of the type is not declared in the
56: * identifiable type
57: */
58: <Y> SingularAttribute<X, Y> getDeclaredVersion(Class<Y> type);
59:
60: /**
61: * Return the identifiable types that corresponds to the most specific mapped
62: * superclass or entity extended by the entity or mapped superclass.
63: *
64: * @return supertype of identifiable type or null if no
65: *
66: * such supertype
67: */
68: Set<? extends IdentifiableType<? super X>> getSupertypes();
69:
70: /**
71: * Whether the identifiable type has a single id attribute. Returns true for
72: * a simple id or embedded id; returns false for an idclass.
73: *
74: * @return boolean indicating whether the identifiable
75: *
76: * type has a single id attribute
77: */
78: boolean hasSingleIdAttribute();
79:
80: /**
81: * Whether the identifiable type has a version attribute.
82: *
83: * @return boolean indicating whether the identifiable
84: *
85: * type has a version attribute
86: */
87: boolean hasVersionAttribute();
88:
89: /**
90: * Return the attribute that corresponds to the id attribute of the entity or mapped superclass.
91: * @return Identifier attribute
92: */
93: @NonJPA
94: Identifier<? super X, ?> getIdentifier();
95: }