Skip to content

Package: ObjectPropertyCollectionDescriptor

ObjectPropertyCollectionDescriptor

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