arminw 2005/04/09 16:09:14
Modified: src/java/org/apache/ojb/broker/core Tag: OJB_1_0_RELEASE
ValueContainer.java
Log:
minor improvement
Revision Changes Path
No revision
No revision
1.7.2.2 +8 -21
db-ojb/src/java/org/apache/ojb/broker/core/ValueContainer.java
Index: ValueContainer.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/ValueContainer.java,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -r1.7.2.1 -r1.7.2.2
--- ValueContainer.java 23 Dec 2004 22:03:25 -0000 1.7.2.1
+++ ValueContainer.java 9 Apr 2005 23:09:14 -0000 1.7.2.2
@@ -24,13 +24,14 @@
{
private static final long serialVersionUID = 3689069556052340793L;
- private JdbcType m_jdbcType;
- private Object m_value;
+ private final JdbcType m_jdbcType;
+ private final Object m_value;
+ private int hc;
public ValueContainer(Object value, JdbcType jdbcType)
{
- setJdbcType(jdbcType);
- setValue(value);
+ this.m_jdbcType = jdbcType;
+ this.m_value = value;
}
public JdbcType getJdbcType()
@@ -38,37 +39,22 @@
return m_jdbcType;
}
- public void setJdbcType(JdbcType jdbcType)
- {
- this.m_jdbcType = jdbcType;
- }
-
public Object getValue()
{
return m_value;
}
- public void setValue(Object value)
- {
- if (value instanceof ValueContainer)
- {
- throw new RuntimeException("We can't nest ValueContainers");
- }
- this.m_value = value;
- }
-
public boolean equals(Object obj)
{
if(obj == this) return true;
boolean result = false;
if(obj instanceof ValueContainer)
{
- ValueContainer container = (ValueContainer) obj;
+ final ValueContainer container = (ValueContainer) obj;
// if jdbcType was null, we can't compare
result = this.m_jdbcType != null ?
this.m_jdbcType.equals(container.getJdbcType()) : false;
if(result)
{
- result = this.m_value == null ? null == container.getValue()
: this.m_value.equals(container.getValue());
result = new EqualsBuilder().append(this.m_value,
container.getValue()).isEquals();
}
}
@@ -80,7 +66,8 @@
// int hash = m_value != null ? m_value.hashCode() : 0;
// hash += m_jdbcType != null ? m_jdbcType.hashCode() : 0;
// return hash;
- return new
HashCodeBuilder().append(m_jdbcType).append(m_value).toHashCode();
+ if(hc == 0) hc = new
HashCodeBuilder().append(m_jdbcType).append(m_value).toHashCode();
+ return hc;
}
public String toString()
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]