DeliveryBuilder { @CanIgnoreReturnValue public DeliveryBuilder setPageSize(int pageSize) { checkArgument(pageSize > 0); this.pageSize = pageSize; return this; } DeliveryBuilder(); Optional<InboxStorage> inboxStorage(); Optional<CatchUpStorage> catchUpStorage(); Optional<DeliveryStrategy> strategy(); Optional<ShardedWorkRegistry> workRegistry(); Optional<Duration> deduplicationWindow(); Optional<DeliveryMonitor> deliveryMonitor(); Optional<Integer> pageSize(); Optional<Integer> catchUpPageSize(); @CanIgnoreReturnValue DeliveryBuilder setWorkRegistry(ShardedWorkRegistry workRegistry); @CanIgnoreReturnValue DeliveryBuilder setStrategy(DeliveryStrategy strategy); @CanIgnoreReturnValue DeliveryBuilder setDeduplicationWindow(Duration deduplicationWindow); @CanIgnoreReturnValue DeliveryBuilder setInboxStorage(InboxStorage inboxStorage); @CanIgnoreReturnValue DeliveryBuilder setCatchUpStorage(CatchUpStorage catchUpStorage); @CanIgnoreReturnValue DeliveryBuilder setMonitor(DeliveryMonitor monitor); @CanIgnoreReturnValue DeliveryBuilder setPageSize(int pageSize); @CanIgnoreReturnValue DeliveryBuilder setCatchUpPageSize(int catchUpPageSize); @SuppressWarnings("PMD.NPathComplexity") // The readability of this method is fine. Delivery build();  }
@Test @DisplayName("accept only positive page size") void acceptOnlyPositivePageSize() { assertThrows(IllegalArgumentException.class, () -> builder().setPageSize(0)); assertThrows(IllegalArgumentException.class, () -> builder().setPageSize(-3)); }