From 0e023365bad9ca1ead4347bd430fc133752151f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Sun, 26 Jul 2009 16:12:16 +0200 Subject: [PATCH] ItEr19S08CUCreacionProxectoPlanificacionItEr18S08: Taking into account the type when calculating if a Dependency is equal to another. --- navalplanner-gantt-zk/pom.xml | 4 +++ .../org/zkoss/ganttz/data/Dependency.java | 25 ++++++------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/navalplanner-gantt-zk/pom.xml b/navalplanner-gantt-zk/pom.xml index 55c942b60..8ffde6340 100644 --- a/navalplanner-gantt-zk/pom.xml +++ b/navalplanner-gantt-zk/pom.xml @@ -22,6 +22,10 @@ commons-logging commons-logging + + commons-lang + commons-lang + org.zkoss.zk diff --git a/navalplanner-gantt-zk/src/main/java/org/zkoss/ganttz/data/Dependency.java b/navalplanner-gantt-zk/src/main/java/org/zkoss/ganttz/data/Dependency.java index 630ab4b05..f62b4398c 100644 --- a/navalplanner-gantt-zk/src/main/java/org/zkoss/ganttz/data/Dependency.java +++ b/navalplanner-gantt-zk/src/main/java/org/zkoss/ganttz/data/Dependency.java @@ -3,6 +3,9 @@ package org.zkoss.ganttz.data; import java.util.Collection; import java.util.Date; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + /** * This class represents a dependency. Contains the source and the destination. * It also specifies the type of the relationship.
@@ -74,12 +77,8 @@ public class Dependency { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((destination == null) ? 0 : destination.hashCode()); - result = prime * result + ((source == null) ? 0 : source.hashCode()); - return result; + return new HashCodeBuilder().append(source).append(destination).append( + type).toHashCode(); } @Override @@ -91,17 +90,9 @@ public class Dependency { if (getClass() != obj.getClass()) return false; Dependency other = (Dependency) obj; - if (destination == null) { - if (other.destination != null) - return false; - } else if (!destination.equals(other.destination)) - return false; - if (source == null) { - if (other.source != null) - return false; - } else if (!source.equals(other.source)) - return false; - return true; + return new EqualsBuilder().append(this.destination, other.destination) + .append(this.source, other.source) + .append(this.type, other.type).isEquals(); } public Task getSource() {