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: import cz.cvut.kbss.ontodriver.util.ErrorUtils;
20:
21: import java.net.URI;
22: import java.util.Objects;
23:
24: final class BaseListDescriptorImpl implements ListDescriptor {
25:
26: private final NamedResource listOwner;
27: private final Assertion listProperty;
28: private final Assertion nextNode;
29:
30: private URI context;
31:
32: public BaseListDescriptorImpl(NamedResource listOwner, Assertion listProperty,
33: Assertion nextNode) {
34: this.listOwner = Objects.requireNonNull(listOwner, ErrorUtils.npxMessage("listOwner"));
35: this.listProperty = Objects.requireNonNull(listProperty, ErrorUtils.npxMessage("listProperty"));
36: this.nextNode = Objects.requireNonNull(nextNode, ErrorUtils.npxMessage("nextNode"));
37: }
38:
39: @Override
40: public URI getContext() {
41: return context;
42: }
43:
44: @Override
45: public void setContext(URI context) {
46: // null permitted here
47: this.context = context;
48: }
49:
50: @Override
51: public NamedResource getListOwner() {
52: return listOwner;
53: }
54:
55: @Override
56: public Assertion getListProperty() {
57: return listProperty;
58: }
59:
60: @Override
61: public Assertion getNextNode() {
62: return nextNode;
63: }
64:
65: @Override
66: public int hashCode() {
67: final int prime = 31;
68: int result = 1;
69: result = prime * result + listOwner.hashCode();
70: result = prime * result + listProperty.hashCode();
71: result = prime * result + nextNode.hashCode();
72: result = prime * result + ((context == null) ? 0 : context.hashCode());
73: return result;
74: }
75:
76: @Override
77: public boolean equals(Object obj) {
78: if (this == obj)
79: return true;
80: if (obj == null)
81: return false;
82: if (getClass() != obj.getClass())
83: return false;
84: BaseListDescriptorImpl other = (BaseListDescriptorImpl) obj;
85: if (!listOwner.equals(other.listOwner))
86: return false;
87: if (!listProperty.equals(other.listProperty))
88: return false;
89: if (!nextNode.equals(other.nextNode))
90: return false;
91: if (context == null) {
92: if (other.context != null)
93: return false;
94: } else if (!context.equals(other.context))
95: return false;
96: return true;
97: }
98:
99: @Override
100: public String toString() {
101: return "owner = " + listOwner + ", list = " + listProperty + ", next node = " + nextNode + ", context = " +
102: context;
103: }
104: }