@Test public void getAll() { Snitch s1 = new StaticSnitch(URI.create("fake: Snitch s2 = new StaticSnitch(URI.create("fake: ArrayList<SnitchRegistry> registries = Lists.newArrayList(StaticSnitchRegistry.of(s1), StaticSnitchRegistry.of(s2)); SnitchRegistry composite = CompositeSnitchRegistry.of(registries); List<Snitch> expected = Arrays.asList(s1, s2); Assert.assertEquals(expected, composite.getAll()); }
@Override public List<Snitch> getAll() { return registries.stream() .map(SnitchRegistry::getAll) .flatMap(Collection::stream) .collect(Collectors.toList()); }
CompositeSnitchRegistry implements SnitchRegistry { @Override public List<Snitch> getAll() { return registries.stream() .map(SnitchRegistry::getAll) .flatMap(Collection::stream) .collect(Collectors.toList()); } }
CompositeSnitchRegistry implements SnitchRegistry { @Override public List<Snitch> getAll() { return registries.stream() .map(SnitchRegistry::getAll) .flatMap(Collection::stream) .collect(Collectors.toList()); } CompositeSnitchRegistry(Collection<SnitchRegistry> registries); }
CompositeSnitchRegistry implements SnitchRegistry { @Override public List<Snitch> getAll() { return registries.stream() .map(SnitchRegistry::getAll) .flatMap(Collection::stream) .collect(Collectors.toList()); } CompositeSnitchRegistry(Collection<SnitchRegistry> registries); static SnitchRegistry of(SnitchRegistry... registries); static SnitchRegistry of(Collection<SnitchRegistry> registries); @Override List<Snitch> getAll(); }
CompositeSnitchRegistry implements SnitchRegistry { @Override public List<Snitch> getAll() { return registries.stream() .map(SnitchRegistry::getAll) .flatMap(Collection::stream) .collect(Collectors.toList()); } CompositeSnitchRegistry(Collection<SnitchRegistry> registries); static SnitchRegistry of(SnitchRegistry... registries); static SnitchRegistry of(Collection<SnitchRegistry> registries); @Override List<Snitch> getAll();  }