Mappings implements Iterable<Mapping<T, R>> { public boolean removeAll(Collection<Mapping<T,R>> mappings){ boolean b = false; for(Mapping<T,R> mapping: mappings){ b |= remove(mapping); } return b; }  void add(Mapping<T, R> mapping); boolean remove(Mapping<T, R> mapping); boolean removeAll(Collection<Mapping<T,R>> mappings); @Override Iterator<Mapping<T, R>> iterator(); int size(); Set<Mapping<T, R>> get(T source); Set<R> getTargets(T source); Set<Mapping<T, R>> get(R target); Set<T> getSources(R target); Set<Mapping<T, R>> get(T source, R target); Set<Mapping<T, R>> getAll();  }
@Test public void testRemoveAll() { Mappings<Task, Resource> mappings = new Mappings<Task, Resource>(); Mapping<Task, Resource> mapping = new Mapping<Task, Resource>("m", new Task("t"), new Resource("r")); mappings.add(mapping); Assert.assertTrue(mappings.removeAll(Collections.singleton(mapping))); Assert.assertEquals(0, mappings.size()); Assert.assertFalse(mappings.removeAll(Collections.singleton(mapping))); }