From 10c85dd48cd4de39dcaa78b965be9cbc6714fe34 Mon Sep 17 00:00:00 2001 From: langella <langella@b8ef2a07-7df7-436f-90b9-41648038564b> Date: Thu, 24 May 2012 07:58:09 +0000 Subject: [PATCH] new msRun equality check git-svn-id: https://subversion.renater.fr/xtandempipeline/trunk@285 b8ef2a07-7df7-436f-90b9-41648038564b --- .../xtandempipeline/class_msms/MsRun.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/MsRun.java b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/MsRun.java index 86dae80c5..bf927ea3a 100644 --- a/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/MsRun.java +++ b/xtandempipeline/src/fr/inra/pappso/xtandempipeline/class_msms/MsRun.java @@ -6,11 +6,12 @@ import org.apache.log4j.Logger; import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataSource; -public class MsRun implements Comparable<MsRun>{ +public class MsRun implements Comparable<MsRun> { private static final Logger logger = Logger.getLogger(MsRun.class); private String sample; - private HashSet<IdentificationDataSource> files = new HashSet<IdentificationDataSource>(0); + private HashSet<IdentificationDataSource> files = new HashSet<IdentificationDataSource>( + 0); public MsRun(String sample_name) { logger.debug("MsRun begin"); @@ -18,10 +19,10 @@ public class MsRun implements Comparable<MsRun>{ } public IdentificationDataSource addFile(IdentificationDataSource file) { - if(files.add(file)) { + if (files.add(file)) { return file; } - for (IdentificationDataSource otherFile:this.files) { + for (IdentificationDataSource otherFile : this.files) { if (file.equals(otherFile)) { return otherFile; } @@ -32,16 +33,25 @@ public class MsRun implements Comparable<MsRun>{ public String getSampleName() { return sample; } - + @Override public int hashCode() { return sample.hashCode(); } - + @Override public boolean equals(Object toCompare) { if (this.hashCode() == toCompare.hashCode()) { - return true; + MsRun msRunCompare = (MsRun) toCompare; + if (this.sample.equals(msRunCompare.sample)) { + return true; + } + + else { + logger.debug("msRun COLLISION on " + sample + " compared to " + + msRunCompare.sample); + + } } return false; } @@ -49,5 +59,5 @@ public class MsRun implements Comparable<MsRun>{ public int compareTo(MsRun arg0) { return this.sample.compareTo(arg0.sample); } - + } -- GitLab