Mappings implements Iterable<Mapping<T, R>> { public Set<R> getTargets(T source) { return targets.get(source).uniqueSet(); }  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 testGetTargets() { Mappings<Task, Resource> mappings = new Mappings<Task, Resource>(); Task t = new Task("t"); Resource r = new Resource("r"); Mapping<Task, Resource> mapping = new Mapping<Task, Resource>("m", t, r); mappings.add(mapping); Assert.assertEquals(Collections.singleton(r), mappings.getTargets(t)); }