1 | |
package org.apache.ojb.broker.core; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
|
20 | |
import org.apache.ojb.broker.metadata.JdbcType; |
21 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
22 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
23 | |
|
24 | |
public final class ValueContainer implements Serializable |
25 | |
{ |
26 | |
private static final long serialVersionUID = 3689069556052340793L; |
27 | |
|
28 | |
private final JdbcType m_jdbcType; |
29 | |
private final Object m_value; |
30 | |
private int hc; |
31 | |
|
32 | |
public ValueContainer(Object value, JdbcType jdbcType) |
33 | |
{ |
34 | |
this.m_jdbcType = jdbcType; |
35 | |
this.m_value = value; |
36 | |
} |
37 | |
|
38 | |
public JdbcType getJdbcType() |
39 | |
{ |
40 | |
return m_jdbcType; |
41 | |
} |
42 | |
|
43 | |
public Object getValue() |
44 | |
{ |
45 | |
return m_value; |
46 | |
} |
47 | |
|
48 | |
public boolean equals(Object obj) |
49 | |
{ |
50 | |
if(obj == this) return true; |
51 | |
boolean result = false; |
52 | |
if(obj instanceof ValueContainer) |
53 | |
{ |
54 | |
final ValueContainer container = (ValueContainer) obj; |
55 | |
|
56 | |
result = this.m_jdbcType != null ? this.m_jdbcType.equals(container.getJdbcType()) : false; |
57 | |
if(result) |
58 | |
{ |
59 | |
result = new EqualsBuilder().append(this.m_value, container.getValue()).isEquals(); |
60 | |
} |
61 | |
} |
62 | |
return result; |
63 | |
} |
64 | |
|
65 | |
public int hashCode() |
66 | |
{ |
67 | |
|
68 | |
|
69 | |
|
70 | |
if(hc == 0) hc = new HashCodeBuilder().append(m_jdbcType).append(m_value).toHashCode(); |
71 | |
return hc; |
72 | |
} |
73 | |
|
74 | |
public String toString() |
75 | |
{ |
76 | |
return this.getClass().getName() + "[jdbcType: " |
77 | |
+ m_jdbcType |
78 | |
+ ", value: " + m_value + "]"; |
79 | |
} |
80 | |
|
81 | |
} |