diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2013-06-25 16:26:13 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2013-06-25 16:26:13 +0200 |
| commit | 4a8dd1a20ddf6c4e1405fe77700baef7e19475e8 (patch) | |
| tree | a5c7881866a545a35647d91e5f7d6f3097e9b605 | |
| parent | 5377997abe18d1dc73d590f914ba21f670778c4a (diff) | |
Initial equals() method for comparison - intended for intelligent module
verification
| -rw-r--r-- | src/main/java/com/c2kernel/collection/Parent2ChildCollection.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/com/c2kernel/collection/Parent2ChildCollection.java b/src/main/java/com/c2kernel/collection/Parent2ChildCollection.java index c59132e..d59b613 100644 --- a/src/main/java/com/c2kernel/collection/Parent2ChildCollection.java +++ b/src/main/java/com/c2kernel/collection/Parent2ChildCollection.java @@ -1,5 +1,7 @@ package com.c2kernel.collection;
+import java.util.Iterator;
+
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.utils.CastorHashMap;
@@ -124,4 +126,18 @@ abstract public class Parent2ChildCollection<E extends CollectionMember> impleme @Override
public abstract E addMember(int entityKey, CastorHashMap props, String classProps) throws MembershipException;
+ public boolean equals(Parent2ChildCollection<?> other) {
+ boolean same = mName.equals(other.getName()) && mURLInfo.equals(other.getURLInfo()) && size() == other.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());
+ if (!thisMem.equals(otherMem)) return false;
+ } catch (ObjectNotFoundException ex) {
+ return false;
+ }
+ }
+ return true;
+ }
}
|
