01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.rdbms.algebra.base;
07:
08: /**
09: * A constant SQL value, like a varchar or number.
10: *
11: * @author James Leigh
12: *
13: */
14: public abstract class SqlConstant<T> extends RdbmsQueryModelNodeBase
15: implements SqlExpr {
16: private T value;
17:
18: public SqlConstant() {
19: super ();
20: }
21:
22: public SqlConstant(T value) {
23: super ();
24: this .value = value;
25: }
26:
27: public T getValue() {
28: return value;
29: }
30:
31: public void setValue(T value) {
32: this .value = value;
33: }
34:
35: @Override
36: public String getSignature() {
37: return super .getSignature() + " " + value;
38: }
39:
40: @Override
41: public SqlConstant<T> clone() {
42: SqlConstant<T> clone = (SqlConstant<T>) super .clone();
43: clone.setValue(value);
44: return clone;
45: }
46:
47: @Override
48: public int hashCode() {
49: final int prime = 31;
50: int result = 1;
51: result = prime * result
52: + ((value == null) ? 0 : value.hashCode());
53: return result;
54: }
55:
56: @Override
57: public boolean equals(Object obj) {
58: if (this == obj)
59: return true;
60: if (obj == null)
61: return false;
62: if (getClass() != obj.getClass())
63: return false;
64: final SqlConstant other = (SqlConstant) obj;
65: if (value == null) {
66: if (other.value != null)
67: return false;
68: } else if (!value.equals(other.value))
69: return false;
70: return true;
71: }
72: }
|