From 7743a511a170ddbd2b9eb77970a54b35c7408e60 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 26 Sep 2014 11:12:51 +0200 Subject: Switch Collection and Job equals() to Object rather than local. --- .../java/com/c2kernel/collection/Collection.java | 9 +++-- src/main/java/com/c2kernel/entity/agent/Job.java | 44 ++++++++++++++++++++-- 2 files changed, 46 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main/java/com/c2kernel/collection/Collection.java b/src/main/java/com/c2kernel/collection/Collection.java index 5cac17c..710420f 100644 --- a/src/main/java/com/c2kernel/collection/Collection.java +++ b/src/main/java/com/c2kernel/collection/Collection.java @@ -126,13 +126,16 @@ abstract public class Collection implements C2KLocal public abstract void removeMember(int memberId) throws MembershipException; - public boolean equals(Collection other) { - boolean same = mName.equals(other.getName()) && mURLInfo.equals(other.getURLInfo()) && size() == other.size(); + @Override + public boolean equals(Object other) { + if (!(other instanceof Collection)) return false; + Collection otherColl = (Collection)other; + boolean same = mName.equals(otherColl.getName()) && mURLInfo.equals(otherColl.getURLInfo()) && size() == otherColl.size(); if (!same) return false; for (Iterator i = getMembers().list.iterator(); i.hasNext();) { try { CollectionMember thisMem = i.next(); - CollectionMember otherMem = other.getMember(thisMem.getID()); + CollectionMember otherMem = otherColl.getMember(thisMem.getID()); if (!thisMem.equals(otherMem)) return false; } catch (ObjectNotFoundException ex) { return false; diff --git a/src/main/java/com/c2kernel/entity/agent/Job.java b/src/main/java/com/c2kernel/entity/agent/Job.java index 0c62bb1..d0d3809 100644 --- a/src/main/java/com/c2kernel/entity/agent/Job.java +++ b/src/main/java/com/c2kernel/entity/agent/Job.java @@ -405,10 +405,46 @@ public class Job implements C2KLocalObject return ClusterStorage.JOB; } - public boolean equals(Job job) - { - return (itemPath.equals(job.getItemPath()) && this.stepPath.equals(job.stepPath) && transition.getId() == job.getTransition().getId()); - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((itemPath == null) ? 0 : itemPath.hashCode()); + result = prime * result + + ((stepPath == null) ? 0 : stepPath.hashCode()); + result = prime * result + + ((transition == null) ? 0 : transition.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Job other = (Job) obj; + if (itemPath == null) { + if (other.itemPath != null) + return false; + } else if (!itemPath.equals(other.itemPath)) + return false; + if (stepPath == null) { + if (other.stepPath != null) + return false; + } else if (!stepPath.equals(other.stepPath)) + return false; + if (transition == null) { + if (other.transition != null) + return false; + } else if (!transition.equals(other.transition)) + return false; + return true; + } + private void setActProps(CastorHashMap actProps) { this.actProps = actProps; -- cgit v1.2.3