Skip to content
Snippets Groups Projects
Commit 10c85dd4 authored by langella's avatar langella
Browse files

new msRun equality check

git-svn-id: https://subversion.renater.fr/xtandempipeline/trunk@285 b8ef2a07-7df7-436f-90b9-41648038564b
parent 4bdd37da
No related branches found
No related tags found
No related merge requests found
...@@ -6,11 +6,12 @@ import org.apache.log4j.Logger; ...@@ -6,11 +6,12 @@ import org.apache.log4j.Logger;
import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataSource; 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 static final Logger logger = Logger.getLogger(MsRun.class);
private String sample; private String sample;
private HashSet<IdentificationDataSource> files = new HashSet<IdentificationDataSource>(0); private HashSet<IdentificationDataSource> files = new HashSet<IdentificationDataSource>(
0);
public MsRun(String sample_name) { public MsRun(String sample_name) {
logger.debug("MsRun begin"); logger.debug("MsRun begin");
...@@ -18,10 +19,10 @@ public class MsRun implements Comparable<MsRun>{ ...@@ -18,10 +19,10 @@ public class MsRun implements Comparable<MsRun>{
} }
public IdentificationDataSource addFile(IdentificationDataSource file) { public IdentificationDataSource addFile(IdentificationDataSource file) {
if(files.add(file)) { if (files.add(file)) {
return file; return file;
} }
for (IdentificationDataSource otherFile:this.files) { for (IdentificationDataSource otherFile : this.files) {
if (file.equals(otherFile)) { if (file.equals(otherFile)) {
return otherFile; return otherFile;
} }
...@@ -32,16 +33,25 @@ public class MsRun implements Comparable<MsRun>{ ...@@ -32,16 +33,25 @@ public class MsRun implements Comparable<MsRun>{
public String getSampleName() { public String getSampleName() {
return sample; return sample;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return sample.hashCode(); return sample.hashCode();
} }
@Override @Override
public boolean equals(Object toCompare) { public boolean equals(Object toCompare) {
if (this.hashCode() == toCompare.hashCode()) { 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; return false;
} }
...@@ -49,5 +59,5 @@ public class MsRun implements Comparable<MsRun>{ ...@@ -49,5 +59,5 @@ public class MsRun implements Comparable<MsRun>{
public int compareTo(MsRun arg0) { public int compareTo(MsRun arg0) {
return this.sample.compareTo(arg0.sample); return this.sample.compareTo(arg0.sample);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment