Explorar o código

Amélioration equals

Arthur Brandao %!s(int64=6) %!d(string=hai) anos
pai
achega
c4e25ec425
Modificáronse 1 ficheiros con 9 adicións e 1 borrados
  1. 9 1
      src/migl/lisp/LispElement.java

+ 9 - 1
src/migl/lisp/LispElement.java

@@ -95,7 +95,15 @@ public class LispElement<E> {
 
 	@Override
 	public boolean equals(Object obj) {
-		return this.value.equals(obj);
+		if(this == obj) {
+			return true;
+		} else if(obj == null) {
+			return false;
+		} else if(obj instanceof LispElement) {
+			LispElement<?> other = (LispElement<?>) obj;
+			return this.value.equals(other.value);
+		}
+		return false;
 	}
 
 	@Override