// /////////////////////////////////////////// // overwriting methods that compare objects of this type // ---equals @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Sample otherSample = (Sample) obj; if (modelNodeToDataNode == null && otherSample.modelNodeToDataNode == null) return true; TreeSet<String> dn1 = this.getIDs(); double mismatch1 = this.getMismatch(); TreeSet<String> rel1 = this.getRelationships(); TreeSet<String> dn2 = otherSample.getIDs(); double mismatch2 = otherSample.getMismatch(); TreeSet<String> rel2 = otherSample.getRelationships(); // System.out.println(mismatch1); // System.out.println(mismatch1); // printSet(dn1); // printSet(dn2); // printSet(rel1); // printSet(rel2); if (mismatch1 == mismatch2 && dn1.equals(dn2) && rel1.equals(rel2)) { // System.out.println("equal"); return true; } // System.out.println("not equal"); return false; }
public Sample copy(boolean copyAdditionalIDs) { Sample newSample = new Sample(); newSample.modelNodeToDataNode = new HashMap<Integer, Integer>(); newSample.dataNodeToModelNode = new HashMap<Integer, Integer>(); newSample.dataIDToDataNodeID = new HashMap<String, Integer>(); newSample.relationshipIDs = new HashMap<String, RelationshipForSample>(); newSample.mismatch = this.mismatch; newSample.mnmrReference = this.mnmrReference; newSample.mnmrSet = this.mnmrSet; newSample.additionalRelationshipIDs = new HashMap<String, ArrayList<String>>(); newSample.ID = this.ID; if (copyAdditionalIDs) { newSample.hasAdditionalIDs = this.hasAdditionalIDs; newSample.additionalIDCount = this.additionalIDCount; copyHashMap(this.additionalRelationshipIDs, newSample.additionalRelationshipIDs); } copyHashMap(this.dataIDToDataNodeID, newSample.dataIDToDataNodeID); copyHashMap(this.dataNodeToModelNode, newSample.dataNodeToModelNode); copyHashMap(this.relationshipIDs, newSample.relationshipIDs); copyHashMap(this.modelNodeToDataNode, newSample.modelNodeToDataNode); return newSample; }