Skip to content

Package: ReferencedListValueDescriptor

ReferencedListValueDescriptor

nameinstructionbranchcomplexitylinemethod
ReferencedListValueDescriptor(NamedResource, Assertion, Assertion, Assertion)
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%
ReferencedListValueDescriptor(NamedResource, Assertion, Assertion, Assertion, boolean)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
addValue(Object)
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%
equals(Object)
M: 39 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
getValues()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hashCode()
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
toString()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2024 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.ontodriver.descriptor;
19:
20: import cz.cvut.kbss.ontodriver.model.Assertion;
21: import cz.cvut.kbss.ontodriver.model.NamedResource;
22:
23: import java.util.ArrayList;
24: import java.util.Collections;
25: import java.util.List;
26: import java.util.Objects;
27:
28: /**
29: * Descriptor of values of a referenced list.
30: *
31: * @param <T> List value type
32: */
33: public class ReferencedListValueDescriptor<T> extends ReferencedListDescriptorImpl implements ListValueDescriptor<T> {
34:
35: private final List<T> values = new ArrayList<>();
36:
37: public ReferencedListValueDescriptor(NamedResource listOwner, Assertion listProperty,
38: Assertion nextNode, Assertion nodeContent) {
39: super(listOwner, listProperty, nextNode, nodeContent);
40: }
41:
42: public ReferencedListValueDescriptor(NamedResource listOwner, Assertion listProperty,
43: Assertion nextNode, Assertion nodeContent, boolean terminatedByNil) {
44: super(listOwner, listProperty, nextNode, nodeContent, terminatedByNil);
45: }
46:
47: @Override
48: public List<T> getValues() {
49: return Collections.unmodifiableList(values);
50: }
51:
52: @Override
53: public void addValue(T value) {
54: Objects.requireNonNull(value);
55: values.add(value);
56: }
57:
58: @Override
59: public int hashCode() {
60: final int prime = 31;
61: int result = super.hashCode();
62: result = prime * result + values.hashCode();
63: return result;
64: }
65:
66: @Override
67: public boolean equals(Object obj) {
68:• if (this == obj) {
69: return true;
70: }
71:• if (obj == null || getClass() != obj.getClass()) {
72: return false;
73: }
74: ReferencedListValueDescriptor<?> other = (ReferencedListValueDescriptor<?>) obj;
75:• if (!descriptor.equals(other.descriptor)) {
76: return false;
77: }
78:• if (!getNodeContent().equals(other.getNodeContent())) {
79: return false;
80: }
81: return values.equals(other.values);
82: }
83:
84: @Override
85: public String toString() {
86: return "[ReferencedListValueDescriptor: owner = " + descriptor.getListOwner() + ", values = " + values + "]";
87: }
88: }