Skip to contentMethod: addValue(NamedResource)
1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.ontodriver.descriptor;
14:
15: import cz.cvut.kbss.ontodriver.model.Assertion;
16: import cz.cvut.kbss.ontodriver.model.NamedResource;
17:
18: import java.util.ArrayList;
19: import java.util.Collections;
20: import java.util.List;
21: import java.util.Objects;
22:
23: public class ReferencedListValueDescriptor extends ReferencedListDescriptorImpl implements
24: ListValueDescriptor {
25:
26: private final List<NamedResource> values;
27:
28: public ReferencedListValueDescriptor(NamedResource listOwner, Assertion listProperty,
29: Assertion nextNode, Assertion nodeContent) {
30: super(listOwner, listProperty, nextNode, nodeContent);
31: this.values = new ArrayList<>();
32: }
33:
34: @Override
35: public List<NamedResource> getValues() {
36: return Collections.unmodifiableList(values);
37: }
38:
39: public void addValue(NamedResource value) {
40: Objects.requireNonNull(value);
41: values.add(value);
42: }
43:
44: @Override
45: public int hashCode() {
46: final int prime = 31;
47: int result = super.hashCode();
48: result = prime * result + values.hashCode();
49: return result;
50: }
51:
52: @Override
53: public boolean equals(Object obj) {
54: if (this == obj)
55: return true;
56: if (obj == null || getClass() != obj.getClass())
57: return false;
58: ReferencedListValueDescriptor other = (ReferencedListValueDescriptor) obj;
59: if (!descriptor.equals(other.descriptor))
60: return false;
61: if (!getNodeContent().equals(other.getNodeContent()))
62: return false;
63: return values.equals(other.values);
64: }
65:
66: @Override
67: public String toString() {
68: return "[ReferencedListValueDescriptor: owner = " + descriptor.getListOwner() + ", values = " + values + "]";
69: }
70: }