Package: SimpleListValueDescriptor
SimpleListValueDescriptor
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SimpleListValueDescriptor(NamedResource, Assertion, Assertion) |
|
|
|
|
|
||||||||||||||||||||
addValue(NamedResource) |
|
|
|
|
|
||||||||||||||||||||
equals(Object) |
|
|
|
|
|
||||||||||||||||||||
getValues() |
|
|
|
|
|
||||||||||||||||||||
hashCode() |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
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.ontodriver.descriptor;
16:
17: import cz.cvut.kbss.ontodriver.model.Assertion;
18: import cz.cvut.kbss.ontodriver.model.NamedResource;
19:
20: import java.util.ArrayList;
21: import java.util.Collections;
22: import java.util.List;
23: import java.util.Objects;
24:
25: /**
26: * Represents values of a simple sequence.
27: *
28: * @author kidney
29: * @see SimpleListDescriptorImpl
30: */
31: public class SimpleListValueDescriptor extends SimpleListDescriptorImpl implements
32: ListValueDescriptor {
33:
34: private final List<NamedResource> values;
35:
36: public SimpleListValueDescriptor(NamedResource listOwner, Assertion listProperty,
37: Assertion nextNodeProperty) {
38: super(listOwner, listProperty, nextNodeProperty);
39: this.values = new ArrayList<>();
40: }
41:
42: @Override
43: public List<NamedResource> getValues() {
44: return Collections.unmodifiableList(values);
45: }
46:
47: @Override
48: public void addValue(NamedResource value) {
49: Objects.requireNonNull(value);
50: values.add(value);
51: }
52:
53: @Override
54: public int hashCode() {
55: final int prime = 31;
56: int result = super.hashCode();
57: result = prime * result + values.hashCode();
58: return result;
59: }
60:
61: @Override
62: public boolean equals(Object obj) {
63:• if (this == obj)
64: return true;
65:• if (obj == null || getClass() != obj.getClass())
66: return false;
67: SimpleListValueDescriptor other = (SimpleListValueDescriptor) obj;
68:• if (!descriptor.equals(other.descriptor)) {
69: return false;
70: }
71: return values.equals(other.values);
72: }
73:
74: @Override
75: public String toString() {
76: return "[SimpleListValueDescriptor: owner = " + descriptor.getListOwner() + ", values = " + values + "]";
77: }
78: }