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%
addAttributeContext(Field, URI)
M: 0 C: 6
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: 6 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: 11 C: 28
72%
M: 6 C: 6
50%
M: 5 C: 2
29%
M: 5 C: 8
62%
M: 0 C: 1
100%
getAttributeDescriptor(FieldSpecification)
M: 2 C: 11
85%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
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%
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%

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.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.Set;
22:
23: public class ObjectPropertyCollectionDescriptor extends FieldDescriptor {
24:
25: private final EntityDescriptor elementDescriptor;
26:
27: public ObjectPropertyCollectionDescriptor(Field attribute) {
28: super(attribute);
29: this.elementDescriptor = new EntityDescriptor();
30: }
31:
32: public ObjectPropertyCollectionDescriptor(URI context, Field attribute) {
33: super(context, attribute);
34: this.elementDescriptor = new EntityDescriptor(context);
35: }
36:
37: @Override
38: public Descriptor getAttributeDescriptor(FieldSpecification<?, ?> attribute) {
39:• if (getField().equals(attribute.getJavaField())) {
40: return this;
41: }
42: return elementDescriptor.getAttributeDescriptor(attribute);
43: }
44:
45: @Override
46: public void addAttributeDescriptor(Field attribute, Descriptor descriptor) {
47: elementDescriptor.addAttributeDescriptor(attribute, descriptor);
48: }
49:
50: @Override
51: public void addAttributeContext(Field attribute, URI context) {
52: elementDescriptor.addAttributeContext(attribute, context);
53: }
54:
55: @Override
56: protected Set<URI> getContextsInternal(Set<URI> contexts, Set<Descriptor> visited) {
57:• if (visited.contains(this)) {
58: return contexts;
59: }
60:• if (contexts == null) {
61: return null;
62: }
63: visited.add(this);
64: contexts.add(context);
65: return elementDescriptor.getContextsInternal(contexts, visited);
66: }
67:
68: @Override
69: public int hashCode() {
70: final int prime = 31;
71: int result = super.hashCode();
72:• result = prime * result + ((elementDescriptor == null) ? 0 : elementDescriptor.hashCode());
73: return result;
74: }
75:
76: @Override
77: public boolean equals(Object obj) {
78:• if (this == obj)
79: return true;
80:• if (!super.equals(obj))
81: return false;
82:• if (getClass() != obj.getClass())
83: return false;
84: ObjectPropertyCollectionDescriptor other = (ObjectPropertyCollectionDescriptor) obj;
85:• if (elementDescriptor == null) {
86:• if (other.elementDescriptor != null)
87: return false;
88:• } else if (!elementDescriptor.equals(other.elementDescriptor))
89: return false;
90: return true;
91: }
92: }