Skip to content

Package: Attribute

Attribute

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: 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: /**
33: * Corresponds to datatype properties
34: */
35: @NonJPA
36: DATA,
37:
38: /**
39: * Corresponds to object properties
40: */
41: @NonJPA
42: OBJECT,
43:
44: /**
45: * Corresponds to annotation properties
46: */
47: @NonJPA
48: ANNOTATION;
49: }
50:
51: /**
52: * Return the persistent attribute type for the attribute.
53: *
54: * @return persistent attribute type
55: */
56: PersistentAttributeType getPersistentAttributeType();
57:
58: /**
59: * Return the java.lang.reflect.Member for the represented attribute.
60: *
61: * @return corresponding java.lang.reflect.Member
62: */
63: @UnusedJPA
64: java.lang.reflect.Member getJavaMember();
65:
66: /**
67: * Return the java.lang.reflect.Member for the represented attribute.
68: *
69: * @return corresponding java.lang.reflect.Member
70: */
71: @NonJPA
72: IRI getIRI();
73:
74: /**
75: * Return the set of cascade types specified for this attribute.
76: *
77: * @return corresponding array of cascade types. This method returns an empty array if no cascade type is specified.
78: * @throws IllegalArgumentException if getPersistentAttributeType() returns DATA or ANNOTATION.
79: */
80: @NonJPA
81: CascadeType[] getCascadeTypes();
82:
83: /**
84: * Is the attribute an association.
85: *
86: * @return boolean indicating whether the attribute corresponds to an association
87: */
88: boolean isAssociation();
89:
90: /**
91: * Whether the attribute can be without value.
92: * <p>
93: * Note that if {@link #getConstraints()} contains {@link ParticipationConstraint}s, this property should be
94: * ignored.
95: *
96: * @return boolean indicating whether the attribute can be empty
97: */
98: boolean isNonEmpty();
99:
100: /**
101: * Does the attribute contain values in lexical form.
102: * <p>
103: * Note that lexical form attributes are effectively read only.
104: * <p>
105: * Applies only to datatype and annotation properties, object properties cannot be in lexical form.
106: *
107: * @return Boolean indicating whether the attribute contains values in lexical form
108: */
109: boolean isLexicalForm();
110:
111: /**
112: * Does the attribute represent simple literals.
113: * <p>
114: * Simple literals are stored as {@code xsd:string}, i.e., strings without language tag.
115: * <p>
116: * Applies only to datatype and annotation properties, object properties cannot be simple literals.
117: *
118: * @return Boolean indicating whether the attribute represents simple literals.
119: */
120: boolean isSimpleLiteral();
121:
122: /**
123: * Returns participation constraints specified for this attribute.
124: *
125: * @return Array of participation constraints
126: */
127: ParticipationConstraint[] getConstraints();
128: }