summaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-09-26 11:12:51 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-09-26 11:12:51 +0200
commit7743a511a170ddbd2b9eb77970a54b35c7408e60 (patch)
tree484f6635f67b3c7a9e9340d9731859bc364a281b /src/main/java/com
parent2ebcedd42cd990b3945707d669e65f6321b0d416 (diff)
Switch Collection and Job equals() to Object rather than local.
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/c2kernel/collection/Collection.java9
-rw-r--r--src/main/java/com/c2kernel/entity/agent/Job.java44
2 files changed, 46 insertions, 7 deletions
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<E extends CollectionMember> 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<E> 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;