From 4a8dd1a20ddf6c4e1405fe77700baef7e19475e8 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 25 Jun 2013 16:26:13 +0200 Subject: Initial equals() method for comparison - intended for intelligent module verification --- .../com/c2kernel/collection/Parent2ChildCollection.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/main/java/com/c2kernel') 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 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 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; + } } -- cgit v1.2.3