forked from bst-mug/trec-2017-precision-medicine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ExperimentsBuilder eases the creation of a set of experiments with a fluent interface and syntactic sugar for decorators. This relates to bst-mug#53.
- Loading branch information
Michel Oleynik
committed
Jul 14, 2017
1 parent
e3bbd6c
commit 901433f
Showing
4 changed files
with
91 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/at/medunigraz/imi/bst/trec/experiment/ExperimentsBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package at.medunigraz.imi.bst.trec.experiment; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import at.medunigraz.imi.bst.trec.query.Query; | ||
|
||
public class ExperimentsBuilder { | ||
|
||
private Set<Experiment> experiments = new HashSet<>(); | ||
|
||
private Experiment buildingExp = null; | ||
|
||
public ExperimentsBuilder() { | ||
} | ||
|
||
public ExperimentsBuilder newExperiment() { | ||
addBuilding(); | ||
buildingExp = new Experiment(); | ||
return this; | ||
} | ||
|
||
public ExperimentsBuilder newExperiment(Experiment base) { | ||
buildingExp = new Experiment(); | ||
buildingExp.setExperimentId(base.getExperimentId()); | ||
buildingExp.setDecorator(base.getDecorator()); | ||
return this; | ||
} | ||
|
||
public ExperimentsBuilder withId(String id) { | ||
buildingExp.setExperimentId(id); | ||
return this; | ||
} | ||
|
||
public ExperimentsBuilder withDecorator(Query decorator) { | ||
buildingExp.setDecorator(decorator); | ||
return this; | ||
} | ||
|
||
public Set<Experiment> build() { | ||
addBuilding(); | ||
return experiments; | ||
} | ||
|
||
private void addBuilding() { | ||
if (buildingExp != null) { | ||
this.experiments.add(buildingExp); | ||
} | ||
} | ||
} |