Author: bayard Date: Sun Jul 18 05:53:30 2010 New Revision: 965162 URL: http://svn.apache.org/viewvc?rev=965162&view=rev Log: Applying Sean Mickey's patch to LANG-630 such that MutableObject.equals is as would be expected. Now it directly overrides the equals(Object) method.
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java?rev=965162&r1=965161&r2=965162&view=diff ============================================================================== --- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java (original) +++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java Sun Jul 18 05:53:30 2010 @@ -76,20 +76,33 @@ public class MutableObject<T> implements //----------------------------------------------------------------------- /** + * <p> * Compares this object against the specified object. The result is <code>true</code> if and only if the argument * is not <code>null</code> and is a <code>MutableObject</code> object that contains the same <code>T</code> * value as this object. + * </p> * - * @param obj the object to compare with, null returns false - * @return <code>true</code> if the objects are the same; <code>false</code> otherwise. + * @param obj the object to compare with, <code>null</code> returns <code>false</code> + * @return <code>true</code> if the objects are the same; + * <code>true</code> if the objects have equivalent <code>value</code> fields; + * <code>false</code> otherwise. */ - public boolean equals(MutableObject<T> obj) { - if(obj == null) { - return false; + @SuppressWarnings("unchecked") + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; } - - T other = obj.value; - return value == other || (value != null && value.equals(other)); + if (this == obj) { + return true; + } + if (this.getClass() == obj.getClass()) { + MutableObject<T> that = (MutableObject<T>) obj; + return this.value.equals(that.value); + } + else { + return false; + } } /**