@Test void defaultProtocolShouldSkipItemsWithNoProtocols() { Optional<Protocol> defaultProtocol = MailRepositoryStoreConfiguration.computeDefaultProtocol(ImmutableList.of( new MailRepositoryStoreConfiguration.Item( ImmutableList.of(), "class.fqdn", new BaseHierarchicalConfiguration()), new MailRepositoryStoreConfiguration.Item( ImmutableList.of(new Protocol("1")), "class.fqdn", new BaseHierarchicalConfiguration()))); assertThat(defaultProtocol).contains(new Protocol("1")); }
static Optional<Protocol> computeDefaultProtocol(List<Item> items) { return items.stream() .flatMap(item -> item.getProtocols().stream()) .findFirst(); }
MailRepositoryStoreConfiguration { static Optional<Protocol> computeDefaultProtocol(List<Item> items) { return items.stream() .flatMap(item -> item.getProtocols().stream()) .findFirst(); } }
MailRepositoryStoreConfiguration { static Optional<Protocol> computeDefaultProtocol(List<Item> items) { return items.stream() .flatMap(item -> item.getProtocols().stream()) .findFirst(); } MailRepositoryStoreConfiguration(List<Item> items, Optional<Protocol> defaultProtocol); }
MailRepositoryStoreConfiguration { static Optional<Protocol> computeDefaultProtocol(List<Item> items) { return items.stream() .flatMap(item -> item.getProtocols().stream()) .findFirst(); } MailRepositoryStoreConfiguration(List<Item> items, Optional<Protocol> defaultProtocol); static MailRepositoryStoreConfiguration forItems(Item... items); static MailRepositoryStoreConfiguration forItems(List<Item> items); static MailRepositoryStoreConfiguration parse(HierarchicalConfiguration<ImmutableNode> configuration); List<Item> getItems(); Optional<Protocol> getDefaultProtocol(); }
MailRepositoryStoreConfiguration { static Optional<Protocol> computeDefaultProtocol(List<Item> items) { return items.stream() .flatMap(item -> item.getProtocols().stream()) .findFirst(); } MailRepositoryStoreConfiguration(List<Item> items, Optional<Protocol> defaultProtocol); static MailRepositoryStoreConfiguration forItems(Item... items); static MailRepositoryStoreConfiguration forItems(List<Item> items); static MailRepositoryStoreConfiguration parse(HierarchicalConfiguration<ImmutableNode> configuration); List<Item> getItems(); Optional<Protocol> getDefaultProtocol();  }