@Test(expected = LinkException.class) public void getUnregisteredLinkFactory() { try { linkFactoryProvider.getLinkFactory(TEST_LINK_TYPE); } catch (LinkException e) { assertThat(e.getMessage()).isEqualTo("No registered LinkFactory linkType=LinkType(FOO)"); throw e; } }
public LinkFactory getLinkFactory(final LinkType linkType) { Objects.requireNonNull(linkType, "linkType must not be null"); return Optional.ofNullable(this.linkFactories.get(linkType)) .orElseThrow(() -> new LinkException( String.format("No registered LinkFactory linkType=%s", linkType), LinkId.of("n/a")) ); }
LinkFactoryProvider { public LinkFactory getLinkFactory(final LinkType linkType) { Objects.requireNonNull(linkType, "linkType must not be null"); return Optional.ofNullable(this.linkFactories.get(linkType)) .orElseThrow(() -> new LinkException( String.format("No registered LinkFactory linkType=%s", linkType), LinkId.of("n/a")) ); } }
LinkFactoryProvider { public LinkFactory getLinkFactory(final LinkType linkType) { Objects.requireNonNull(linkType, "linkType must not be null"); return Optional.ofNullable(this.linkFactories.get(linkType)) .orElseThrow(() -> new LinkException( String.format("No registered LinkFactory linkType=%s", linkType), LinkId.of("n/a")) ); } LinkFactoryProvider();  LinkFactoryProvider(final Map<LinkType, LinkFactory> linkFactories); }
LinkFactoryProvider { public LinkFactory getLinkFactory(final LinkType linkType) { Objects.requireNonNull(linkType, "linkType must not be null"); return Optional.ofNullable(this.linkFactories.get(linkType)) .orElseThrow(() -> new LinkException( String.format("No registered LinkFactory linkType=%s", linkType), LinkId.of("n/a")) ); } LinkFactoryProvider();  LinkFactoryProvider(final Map<LinkType, LinkFactory> linkFactories); LinkFactory getLinkFactory(final LinkType linkType); LinkFactory registerLinkFactory(final LinkType linkType, final LinkFactory linkFactory); }
LinkFactoryProvider { public LinkFactory getLinkFactory(final LinkType linkType) { Objects.requireNonNull(linkType, "linkType must not be null"); return Optional.ofNullable(this.linkFactories.get(linkType)) .orElseThrow(() -> new LinkException( String.format("No registered LinkFactory linkType=%s", linkType), LinkId.of("n/a")) ); } LinkFactoryProvider();  LinkFactoryProvider(final Map<LinkType, LinkFactory> linkFactories); LinkFactory getLinkFactory(final LinkType linkType); LinkFactory registerLinkFactory(final LinkType linkType, final LinkFactory linkFactory);  }