Skip to content

Method: setContext(URI)

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.net.URI;
21: import java.util.Objects;
22:
23: /**
24: * Represents singly-linked referenced list. </p>
25: * <p>
26: * In referenced list each node has content linked to it by a separate property. In addition, each node points to its
27: * successor in the sequence (with the exception of the last node, which has no successor).
28: *
29: * @author ledvima1
30: */
31: public class ReferencedListDescriptorImpl implements ReferencedListDescriptor {
32:
33: protected final ListDescriptor descriptor;
34: private final Assertion nodeContent;
35:
36: public ReferencedListDescriptorImpl(NamedResource listOwner, Assertion listProperty,
37: Assertion nextNode, Assertion nodeContent) {
38: this.descriptor = new BaseListDescriptorImpl(listOwner, listProperty, nextNode);
39: this.nodeContent = Objects.requireNonNull(nodeContent);
40: }
41:
42: @Override
43: public URI getContext() {
44: return descriptor.getContext();
45: }
46:
47: @Override
48: public void setContext(URI context) {
49: descriptor.setContext(context);
50: }
51:
52: @Override
53: public NamedResource getListOwner() {
54: return descriptor.getListOwner();
55: }
56:
57: @Override
58: public Assertion getListProperty() {
59: return descriptor.getListProperty();
60: }
61:
62: @Override
63: public Assertion getNextNode() {
64: return descriptor.getNextNode();
65: }
66:
67: @Override
68: public Assertion getNodeContent() {
69: return nodeContent;
70: }
71:
72: @Override
73: public int hashCode() {
74: final int prime = 31;
75: int result = 1;
76: result = prime * result + descriptor.hashCode();
77: result = prime * result + nodeContent.hashCode();
78: return result;
79: }
80:
81: @Override
82: public boolean equals(Object obj) {
83: if (this == obj)
84: return true;
85: if (obj == null)
86: return false;
87: if (getClass() != obj.getClass())
88: return false;
89: ReferencedListDescriptorImpl other = (ReferencedListDescriptorImpl) obj;
90: if (!descriptor.equals(other.descriptor))
91: return false;
92: if (!nodeContent.equals(other.nodeContent))
93: return false;
94: return true;
95: }
96:
97: @Override
98: public String toString() {
99: return "[ReferencedList: " + descriptor + ", nodeContent = " + nodeContent + "]";
100: }
101: }