Skip to content

Package: ObjectPropertyCollectionDescriptor

ObjectPropertyCollectionDescriptor

nameinstructionbranchcomplexitylinemethod
ObjectPropertyCollectionDescriptor(FieldSpecification)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
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: * JOPA
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.model.descriptors;
19:
20: import cz.cvut.kbss.jopa.model.metamodel.FieldSpecification;
21:
22: import java.net.URI;
23: import java.util.Objects;
24: import java.util.Set;
25:
26: /**
27: * Allows to provide descriptor for elements of an object property collection.
28: */
29: public class ObjectPropertyCollectionDescriptor extends FieldDescriptor {
30:
31: private final EntityDescriptor elementDescriptor;
32:
33: public ObjectPropertyCollectionDescriptor(FieldSpecification<?, ?> attribute) {
34: super(attribute);
35: this.elementDescriptor = new EntityDescriptor();
36: }
37:
38: public ObjectPropertyCollectionDescriptor(URI context, FieldSpecification<?, ?> attribute) {
39: super(context, attribute);
40: this.elementDescriptor = new EntityDescriptor(context);
41: }
42:
43: public ObjectPropertyCollectionDescriptor(Set<URI> contexts, FieldSpecification<?, ?> attribute) {
44: super(contexts, attribute);
45: this.elementDescriptor = new EntityDescriptor(contexts);
46: }
47:
48: public ObjectPropertyCollectionDescriptor(URI context, FieldSpecification<?, ?> attribute,
49: boolean assertionsInSubjectContext) {
50: super(context, attribute);
51: this.elementDescriptor = new EntityDescriptor(context, assertionsInSubjectContext);
52: }
53:
54: @Override
55: public Descriptor getAttributeDescriptor(FieldSpecification<?, ?> attribute) {
56: Objects.requireNonNull(attribute);
57:• if (getField().equals(attribute.getJavaField())) {
58: return this;
59: }
60: return elementDescriptor.getAttributeDescriptor(attribute);
61: }
62:
63: @Override
64: public Set<URI> getAttributeContexts(FieldSpecification<?, ?> attribute) {
65: Objects.requireNonNull(attribute);
66:• if (getField().equals(attribute.getJavaField())) {
67: return getContexts();
68: }
69: return elementDescriptor.getAttributeContexts(attribute);
70: }
71:
72: @Override
73: public ObjectPropertyCollectionDescriptor addAttributeDescriptor(FieldSpecification<?, ?> attribute,
74: Descriptor descriptor) {
75: elementDescriptor.addAttributeDescriptor(attribute, descriptor);
76: return this;
77: }
78:
79: @Override
80: public ObjectPropertyCollectionDescriptor addAttributeContext(FieldSpecification<?, ?> attribute, URI context) {
81: elementDescriptor.addAttributeContext(attribute, context);
82: return this;
83: }
84:
85: @Override
86: public boolean overridesAssertionContext() {
87: return false;
88: }
89:
90: public EntityDescriptor getElementDescriptor() {
91: return elementDescriptor;
92: }
93:
94: @Override
95: public int hashCode() {
96: final int prime = 31;
97: int result = super.hashCode();
98:• result = prime * result + ((elementDescriptor == null) ? 0 : elementDescriptor.hashCode());
99: return result;
100: }
101:
102: @Override
103: public boolean equals(Object obj) {
104:• if (this == obj)
105: return true;
106:• if (!super.equals(obj))
107: return false;
108:• if (getClass() != obj.getClass())
109: return false;
110: ObjectPropertyCollectionDescriptor other = (ObjectPropertyCollectionDescriptor) obj;
111:• if (elementDescriptor == null) {
112:• return other.elementDescriptor == null;
113: } else return elementDescriptor.equals(other.elementDescriptor);
114: }
115: }