Skip to content

Package: PropertyAttributes

PropertyAttributes

nameinstructionbranchcomplexitylinemethod
PropertyAttributes(FieldMappingValidator)
M: 0 C: 29
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
create(Field, FieldMappingValidator)
M: 0 C: 32
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
getCascadeTypes()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getFetchType()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getIri()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getParticipationConstraints()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPersistentAttributeType()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getType()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isKnownOwlProperty()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isNonEmpty()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
resolve(Field, MetamodelImpl, Class)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
resolveParticipationConstraints(Field)
M: 0 C: 24
100%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 6
100%
M: 0 C: 1
100%

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.model.IRI;
18: import cz.cvut.kbss.jopa.model.MetamodelImpl;
19: import cz.cvut.kbss.jopa.model.annotations.*;
20:
21: import java.lang.reflect.Field;
22:
23: abstract class PropertyAttributes {
24:
25: final FieldMappingValidator validator;
26:
27: Type<?> type = null;
28: Attribute.PersistentAttributeType persistentAttributeType = null;
29: IRI iri = null;
30: CascadeType[] cascadeTypes = new CascadeType[]{};
31: FetchType fetchType = FetchType.EAGER;
32: boolean nonEmpty = false;
33: ParticipationConstraint[] participationConstraints = new ParticipationConstraint[]{};
34:
35: PropertyAttributes(FieldMappingValidator validator) {
36: this.validator = validator;
37: }
38:
39: Type<?> getType() {
40: return type;
41: }
42:
43: Attribute.PersistentAttributeType getPersistentAttributeType() {
44: return persistentAttributeType;
45: }
46:
47: IRI getIri() {
48: return iri;
49: }
50:
51: CascadeType[] getCascadeTypes() {
52: return cascadeTypes;
53: }
54:
55: FetchType getFetchType() {
56: return fetchType;
57: }
58:
59: boolean isKnownOwlProperty() {
60: return true;
61: }
62:
63: boolean isNonEmpty() {
64: return nonEmpty;
65: }
66:
67: ParticipationConstraint[] getParticipationConstraints() {
68: return participationConstraints;
69: }
70:
71: void resolve(Field field, MetamodelImpl metamodel, Class<?> fieldValueCls) {
72: resolveParticipationConstraints(field);
73: }
74:
75: void resolveParticipationConstraints(Field field) {
76: ParticipationConstraints cons = field.getAnnotation(ParticipationConstraints.class);
77:• if (cons != null) {
78:• if (cons.value() != null && cons.value().length > 0) {
79: this.participationConstraints = cons.value();
80: } else {
81: this.nonEmpty = cons.nonEmpty();
82: }
83: }
84: }
85:
86: static PropertyAttributes create(Field field, FieldMappingValidator validator) {
87:• if (field.getAnnotation(OWLObjectProperty.class) != null) {
88: return new ObjectPropertyAttributes(validator);
89:• } else if (field.getAnnotation(OWLDataProperty.class) != null) {
90: return new DataPropertyAttributes(validator);
91:• } else if (field.getAnnotation(OWLAnnotationProperty.class) != null) {
92: return new AnnotationPropertyAttributes(validator);
93: } else {
94: return new NonPropertyAttributes(validator);
95: }
96: }
97:
98: private static class NonPropertyAttributes extends PropertyAttributes {
99:
100: NonPropertyAttributes(FieldMappingValidator validator) {
101: super(validator);
102: }
103:
104: @Override
105: boolean isKnownOwlProperty() {
106: return false;
107: }
108:
109: @Override
110: void resolve(Field field, MetamodelImpl metamodel, Class<?> fieldValueCls) {
111: // do nothing
112: }
113: }
114: }