diff --git a/src/java/org/apache/commons/lang/mutable/Mutable.java b/src/java/org/apache/commons/lang/mutable/Mutable.java index 10247ebae..6c3a0c2e8 100644 --- a/src/java/org/apache/commons/lang/mutable/Mutable.java +++ b/src/java/org/apache/commons/lang/mutable/Mutable.java @@ -30,14 +30,14 @@ package org.apache.commons.lang.mutable; * @since 2.1 * @version $Id$ */ -public interface Mutable { +public interface Mutable { /** * Gets the value of this mutable. * * @return the stored value */ - Object getValue(); + T getValue(); /** * Sets the value of this mutable. @@ -49,6 +49,6 @@ public interface Mutable { * @throws ClassCastException * if the type is invalid */ - void setValue(Object value); + void setValue(T value); } diff --git a/src/java/org/apache/commons/lang/mutable/MutableObject.java b/src/java/org/apache/commons/lang/mutable/MutableObject.java index 38ccdf98b..8746859ce 100644 --- a/src/java/org/apache/commons/lang/mutable/MutableObject.java +++ b/src/java/org/apache/commons/lang/mutable/MutableObject.java @@ -25,7 +25,7 @@ import java.io.Serializable; * @since 2.1 * @version $Id$ */ -public class MutableObject implements Mutable, Serializable { +public class MutableObject implements Mutable, Serializable { /** * Required for serialization support. @@ -35,7 +35,7 @@ public class MutableObject implements Mutable, Serializable { private static final long serialVersionUID = 86241875189L; /** The mutable value. */ - private Object value; + private T value; /** * Constructs a new MutableObject with the default value of null. @@ -50,7 +50,7 @@ public class MutableObject implements Mutable, Serializable { * @param value * a value. */ - public MutableObject(Object value) { + public MutableObject(T value) { super(); this.value = value; } @@ -61,7 +61,7 @@ public class MutableObject implements Mutable, Serializable { * * @return the value */ - public Object getValue() { + public T getValue() { return this.value; } @@ -71,27 +71,27 @@ public class MutableObject implements Mutable, Serializable { * @param value * the value to set */ - public void setValue(Object value) { + public void setValue(T value) { this.value = value; } //----------------------------------------------------------------------- /** * Compares this object against the specified object. The result is true if and only if the argument - * is not null and is a MutableObject object that contains the same Object + * is not null and is a MutableObject object that contains the same T * value as this object. * * @param obj * the object to compare with. * @return true if the objects are the same; false otherwise. */ - @Override - public boolean equals(Object obj) { - if (obj instanceof MutableObject) { - Object other = ((MutableObject) obj).value; - return value == other || (value != null && value.equals(other)); + public boolean equals(MutableObject obj) { + if(obj == null) { + return false; } - return false; + + T other = obj.value; + return value == other || (value != null && value.equals(other)); } /**