Study extends StudyData implements Observable, Comparable<Study> { public boolean containsTreatment(final Treatment t) { return CollectionUtils.exists(getMeasurements(), new Predicate<Measurement>() { public boolean evaluate(Measurement m) { return m.getTreatment().equals(t); } }); } Study();  Study(String id); @Override void setId(String newValue); @SuppressWarnings({ "unchecked", "rawtypes" }) ObservableList<Measurement> getMeasurements(); void addPropertyChangeListener(PropertyChangeListener listener); void removePropertyChangeListener(PropertyChangeListener listener); @Override String toString(); Study restrictMeasurements(DataType type); boolean containsTreatment(final Treatment t); Set<Treatment> getTreatments(); @Override boolean equals(Object o); @Override int hashCode(); int compareTo(Study s); static final String PROPERTY_ID; }
@Test public void testContainsTreatment() { Study s1 = new Study("1"); s1.getMeasurements().add(new Measurement(new Treatment("A"))); s1.getMeasurements().add(new Measurement(new Treatment("B"))); s1.getMeasurements().add(new Measurement(new Treatment("C"))); assertTrue(s1.containsTreatment(new Treatment("A"))); assertTrue(s1.containsTreatment(new Treatment("B"))); assertTrue(s1.containsTreatment(new Treatment("C"))); assertFalse(s1.containsTreatment(new Treatment("D"))); }