Skip to contentPackage: Attribute
Attribute
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: import cz.cvut.kbss.jopa.model.IRI;
20: import cz.cvut.kbss.jopa.model.annotations.CascadeType;
21: import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraint;
22:
23: /**
24: * Represents an attribute of a Java type.
25: *
26: * @param <X> The represented type that contains the attribute
27: * @param <Y> The type of the represented attribute
28: */
29: public interface Attribute<X, Y> extends FieldSpecification<X, Y> {
30:
31: enum PersistentAttributeType {
32: // @UnusedJPA
33: // @Deprecated
34: // MANY_TO_ONE,
35: //
36: // @UnusedJPA
37: // @Deprecated
38: // ONE_TO_ONE,
39: //
40: // /**
41: // * correspond to the datatype properties
42: // */
43: // @UnusedJPA
44: // @Deprecated
45: // BASIC,
46:
47: /**
48: * correspond to the object properties
49: */
50: @NonJPA
51: DATA,
52:
53: /**
54: * correspond to the object properties
55: */
56: @NonJPA
57: OBJECT,
58:
59: /**
60: * correspond to the object properties
61: */
62: @NonJPA
63: ANNOTATION,
64:
65: // @UnusedJPA
66: // @Deprecated
67: // EMBEDDED,
68: //
69: // @UnusedJPA
70: // @Deprecated
71: // MANY_TO_MANY,
72: //
73: // @UnusedJPA
74: // @Deprecated
75: // ONE_TO_MANY,
76: //
77: // @UnusedJPA
78: // @Deprecated
79: // ELEMENT_COLLECTION
80: }
81:
82: /**
83: * Return the persistent attribute type for the attribute.
84: *
85: * @return persistent attribute type
86: */
87: PersistentAttributeType getPersistentAttributeType();
88:
89: /**
90: * Return the java.lang.reflect.Member for the represented attribute.
91: *
92: * @return corresponding java.lang.reflect.Member
93: */
94: @UnusedJPA
95: @Deprecated
96: java.lang.reflect.Member getJavaMember();
97:
98: /**
99: * Return the java.lang.reflect.Member for the represented attribute.
100: *
101: * @return corresponding java.lang.reflect.Member
102: */
103: @NonJPA
104: IRI getIRI();
105:
106: /**
107: * Return the set of cascadetypes specified for this attribute.
108: *
109: * @return corresponding array of cascade types. This method returns an empty array if no cascade type is specified.
110: * @throws IllegalArgumentException if getPersistentAttributeType() returns DATA or ANNOTATION.
111: */
112: @NonJPA
113: CascadeType[] getCascadeTypes();
114:
115: /**
116: * Is the attribute an association.
117: *
118: * @return boolean indicating whether the attribute corresponds to an association
119: */
120: boolean isAssociation();
121:
122: /**
123: * Is the attribute collection-valued (represents a Collection, Set, List, or Map).
124: *
125: * @return boolean indicating whether the attribute is collection-valued
126: */
127: boolean isCollection();
128:
129: /**
130: * Whether the attribute can be without value.
131: * <p>
132: * Note that if {@link #getConstraints()} contains {@link ParticipationConstraint}s, this property should be
133: * ignored.
134: *
135: * @return boolean indicating whether the attribute can be empty
136: */
137: boolean isNonEmpty();
138:
139: ParticipationConstraint[] getConstraints();
140: }