Skip to content

Package: ObjectPropertyAttributes

ObjectPropertyAttributes

nameinstructionbranchcomplexitylinemethod
ObjectPropertyAttributes(FieldMappingValidator)
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%
initPlainIdentifierAttribute(Class)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
resolve(Field, MetamodelBuilder, Class)
M: 4 C: 47
92%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 11
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

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.model.IRI;
18: import cz.cvut.kbss.jopa.model.annotations.CascadeType;
19: import cz.cvut.kbss.jopa.model.annotations.FetchType;
20: import cz.cvut.kbss.jopa.model.annotations.OWLObjectProperty;
21:
22: import java.lang.reflect.Field;
23:
24: class ObjectPropertyAttributes extends PropertyAttributes {
25:
26: ObjectPropertyAttributes(FieldMappingValidator validator) {
27: super(validator);
28: }
29:
30: @Override
31: void resolve(Field field, MetamodelBuilder metamodelBuilder, Class<?> fieldValueCls) {
32: super.resolve(field, metamodelBuilder, fieldValueCls);
33: final OWLObjectProperty oop = field.getAnnotation(OWLObjectProperty.class);
34:• assert oop != null;
35:
36: this.persistentAttributeType = Attribute.PersistentAttributeType.OBJECT;
37: this.iri = IRI.create(typeBuilderContext.resolveNamespace(oop.iri()));
38:
39:• if (validator.isValidIdentifierType(fieldValueCls)) {
40: initPlainIdentifierAttribute(fieldValueCls);
41: } else {
42: this.type = metamodelBuilder.getEntityClass(fieldValueCls);
43: this.cascadeTypes = oop.cascade();
44: this.fetchType = oop.fetch();
45: }
46: }
47:
48: private void initPlainIdentifierAttribute(Class<?> targetType) {
49: this.type = BasicTypeImpl.get(targetType);
50: this.cascadeTypes = new CascadeType[0];
51: this.fetchType = FetchType.EAGER;
52: }
53: }