Skip to content

Package: ObjectPropertyCollectionDescriptor

ObjectPropertyCollectionDescriptor

nameinstructionbranchcomplexitylinemethod
ObjectPropertyCollectionDescriptor(Field)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
ObjectPropertyCollectionDescriptor(URI, Field)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
ObjectPropertyCollectionDescriptor(URI, Field, boolean)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
addAttributeContext(Field, URI)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addAttributeDescriptor(Field, Descriptor)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
equals(Object)
M: 13 C: 24
65%
M: 6 C: 4
40%
M: 5 C: 1
17%
M: 4 C: 6
60%
M: 0 C: 1
100%
getAttributeContext(FieldSpecification)
M: 0 C: 17
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getAttributeDescriptor(FieldSpecification)
M: 0 C: 16
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getContextsInternal(Set, Set)
M: 25 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getElementDescriptor()
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%
hashCode()
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
overridesAssertionsInSubjectContext()
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%

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.descriptors;
16:
17: import cz.cvut.kbss.jopa.model.metamodel.FieldSpecification;
18:
19: import java.lang.reflect.Field;
20: import java.net.URI;
21: import java.util.Objects;
22: import java.util.Set;
23:
24: /**
25: * Allows to provide descriptor for elements of an object property collection.
26: */
27: public class ObjectPropertyCollectionDescriptor extends FieldDescriptor {
28:
29: private final EntityDescriptor elementDescriptor;
30:
31: public ObjectPropertyCollectionDescriptor(Field attribute) {
32: super(attribute);
33: this.elementDescriptor = new EntityDescriptor();
34: }
35:
36: public ObjectPropertyCollectionDescriptor(URI context, Field attribute) {
37: super(context, attribute);
38: this.elementDescriptor = new EntityDescriptor(context);
39: }
40:
41: public ObjectPropertyCollectionDescriptor(URI context, Field attribute, boolean assertionsInSubjectContext) {
42: super(context, attribute);
43: this.elementDescriptor = new EntityDescriptor(context, assertionsInSubjectContext);
44: }
45:
46: @Override
47: public Descriptor getAttributeDescriptor(FieldSpecification<?, ?> attribute) {
48: Objects.requireNonNull(attribute);
49:• if (getField().equals(attribute.getJavaField())) {
50: return this;
51: }
52: return elementDescriptor.getAttributeDescriptor(attribute);
53: }
54:
55: @Override
56: public URI getAttributeContext(FieldSpecification<?, ?> attribute) {
57: Objects.requireNonNull(attribute);
58:• if (getField().equals(attribute.getJavaField())) {
59: return getContext();
60: }
61: return elementDescriptor.getAttributeContext(attribute);
62: }
63:
64: @Override
65: public ObjectPropertyCollectionDescriptor addAttributeDescriptor(Field attribute, Descriptor descriptor) {
66: elementDescriptor.addAttributeDescriptor(attribute, descriptor);
67: return this;
68: }
69:
70: @Override
71: public ObjectPropertyCollectionDescriptor addAttributeContext(Field attribute, URI context) {
72: elementDescriptor.addAttributeContext(attribute, context);
73: return this;
74: }
75:
76: @Override
77: protected Set<URI> getContextsInternal(Set<URI> contexts, Set<Descriptor> visited) {
78:• if (visited.contains(this)) {
79: return contexts;
80: }
81:• if (contexts == null) {
82: return null;
83: }
84: visited.add(this);
85: contexts.add(context);
86: return elementDescriptor.getContextsInternal(contexts, visited);
87: }
88:
89: @Override
90: protected boolean overridesAssertionsInSubjectContext() {
91: return false;
92: }
93:
94: public EntityDescriptor getElementDescriptor() {
95: return elementDescriptor;
96: }
97:
98: @Override
99: public int hashCode() {
100: final int prime = 31;
101: int result = super.hashCode();
102:• result = prime * result + ((elementDescriptor == null) ? 0 : elementDescriptor.hashCode());
103: return result;
104: }
105:
106: @Override
107: public boolean equals(Object obj) {
108:• if (this == obj)
109: return true;
110:• if (!super.equals(obj))
111: return false;
112:• if (getClass() != obj.getClass())
113: return false;
114: ObjectPropertyCollectionDescriptor other = (ObjectPropertyCollectionDescriptor) obj;
115:• if (elementDescriptor == null) {
116:• return other.elementDescriptor == null;
117: } else return elementDescriptor.equals(other.elementDescriptor);
118: }
119: }