From a25fda149bdf2e802c70eb90f0c77031fc415c9d Mon Sep 17 00:00:00 2001 From: sogabe Date: Sun, 31 Jan 2010 09:32:00 +0000 Subject: [PATCH] [FIXED HUDSON-5293] added equals() and hashcode() to Dependecy.class so that contains method can work correctly. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@26798 71c3de6d-444a-0410-be80-ed276b4c234a --- .../java/hudson/model/DependencyGraph.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/DependencyGraph.java b/core/src/main/java/hudson/model/DependencyGraph.java index f25c735dd7..24fe8d11f2 100644 --- a/core/src/main/java/hudson/model/DependencyGraph.java +++ b/core/src/main/java/hudson/model/DependencyGraph.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Martin Eigenbrodt + * Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Martin Eigenbrodt. Seiji Sogabe * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -433,5 +433,27 @@ public final class DependencyGraph implements Comparator { List actions) { return true; } + + @Override + public boolean equals(Object obj) { + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + + final Dependency other = (Dependency) obj; + if (this.upstream != other.upstream && (this.upstream == null || !this.upstream.equals(other.upstream))) + return false; + if (this.downstream != other.downstream && (this.downstream == null || !this.downstream.equals(other.downstream))) + return false; + + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 23 * hash + (this.upstream != null ? this.upstream.hashCode() : 0); + hash = 23 * hash + (this.downstream != null ? this.downstream.hashCode() : 0); + return hash; + } } }