@Test public void testCompositeRegistryEventConsumer() { List<RegistryEventConsumer<String>> consumers = new ArrayList<>(); TestRegistryEventConsumer registryEventConsumer1 = new TestRegistryEventConsumer(); TestRegistryEventConsumer registryEventConsumer2 = new TestRegistryEventConsumer(); consumers.add(registryEventConsumer1); consumers.add(registryEventConsumer2); CompositeRegistryEventConsumer<String> compositeRegistryEventConsumer = new CompositeRegistryEventConsumer<>( consumers); TestRegistry testRegistry = new TestRegistry(compositeRegistryEventConsumer); String addedEntry1 = testRegistry.computeIfAbsent("name", () -> "entry1"); assertThat(addedEntry1).isEqualTo("entry1"); String addedEntry2 = testRegistry.computeIfAbsent("name2", () -> "entry2"); assertThat(addedEntry2).isEqualTo("entry2"); Optional<String> removedEntry = testRegistry.remove("name"); assertThat(removedEntry).isNotEmpty().hasValue("entry1"); Optional<String> replacedEntry = testRegistry.replace("name2", "entry3"); assertThat(replacedEntry).isNotEmpty().hasValue("entry2"); assertConsumer(registryEventConsumer1); assertConsumer(registryEventConsumer2); }
public CompositeRegistryEventConsumer(List<RegistryEventConsumer<E>> delegates) { this.delegates = new ArrayList<>(requireNonNull(delegates)); }
CompositeRegistryEventConsumer implements RegistryEventConsumer<E> { public CompositeRegistryEventConsumer(List<RegistryEventConsumer<E>> delegates) { this.delegates = new ArrayList<>(requireNonNull(delegates)); } }
CompositeRegistryEventConsumer implements RegistryEventConsumer<E> { public CompositeRegistryEventConsumer(List<RegistryEventConsumer<E>> delegates) { this.delegates = new ArrayList<>(requireNonNull(delegates)); } CompositeRegistryEventConsumer(List<RegistryEventConsumer<E>> delegates); }
CompositeRegistryEventConsumer implements RegistryEventConsumer<E> { public CompositeRegistryEventConsumer(List<RegistryEventConsumer<E>> delegates) { this.delegates = new ArrayList<>(requireNonNull(delegates)); } CompositeRegistryEventConsumer(List<RegistryEventConsumer<E>> delegates); @Override void onEntryAddedEvent(EntryAddedEvent<E> entryAddedEvent); @Override void onEntryRemovedEvent(EntryRemovedEvent<E> entryRemoveEvent); @Override void onEntryReplacedEvent(EntryReplacedEvent<E> entryReplacedEvent); }
CompositeRegistryEventConsumer implements RegistryEventConsumer<E> { public CompositeRegistryEventConsumer(List<RegistryEventConsumer<E>> delegates) { this.delegates = new ArrayList<>(requireNonNull(delegates)); } CompositeRegistryEventConsumer(List<RegistryEventConsumer<E>> delegates); @Override void onEntryAddedEvent(EntryAddedEvent<E> entryAddedEvent); @Override void onEntryRemovedEvent(EntryRemovedEvent<E> entryRemoveEvent); @Override void onEntryReplacedEvent(EntryReplacedEvent<E> entryReplacedEvent);  }