Skip to content

Package: PropertyAttributes$NonPropertyAttributes

PropertyAttributes$NonPropertyAttributes

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