01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.http.protocol.transaction.operations;
07:
08: import info.aduna.lang.ObjectUtil;
09:
10: import org.openrdf.model.Resource;
11: import org.openrdf.model.URI;
12: import org.openrdf.model.Value;
13:
14: /**
15: * A context operation with (optional) subject, predicate, object.
16: *
17: * @author Arjohn Kampman
18: */
19: public abstract class StatementOperation extends ContextOperation {
20:
21: private Resource subject;
22:
23: private URI predicate;
24:
25: private Value object;
26:
27: protected StatementOperation(Resource... contexts) {
28: super (contexts);
29: }
30:
31: public Resource getSubject() {
32: return subject;
33: }
34:
35: public void setSubject(Resource subject) {
36: this .subject = subject;
37: }
38:
39: public URI getPredicate() {
40: return predicate;
41: }
42:
43: public void setPredicate(URI predicate) {
44: this .predicate = predicate;
45: }
46:
47: public Value getObject() {
48: return object;
49: }
50:
51: public void setObject(Value object) {
52: this .object = object;
53: }
54:
55: @Override
56: public boolean equals(Object other) {
57: if (other instanceof StatementOperation) {
58: StatementOperation o = (StatementOperation) other;
59:
60: return ObjectUtil.nullEquals(getSubject(), o.getSubject())
61: && ObjectUtil.nullEquals(getPredicate(), o
62: .getPredicate())
63: && ObjectUtil
64: .nullEquals(getObject(), o.getObject())
65: && super .equals(other);
66: }
67:
68: return false;
69: }
70:
71: @Override
72: public int hashCode() {
73: int hashCode = ObjectUtil.nullHashCode(getSubject());
74: hashCode = 31 * hashCode
75: + ObjectUtil.nullHashCode(getPredicate());
76: hashCode = 31 * hashCode + ObjectUtil.nullHashCode(getObject());
77: hashCode = 31 * hashCode + super.hashCode();
78: return hashCode;
79: }
80: }
|