@Test(expected = LinkException.class) public void constructLinkWithUnsupportedLinkType() { try { LinkSettings linkSettings = LinkSettings.builder() .linkType(LinkType.of("foo")) .build(); pingLoopbackLinkFactory.constructLink(() -> OPERATOR_ADDRESS, linkSettings); fail(); } catch (NullPointerException e) { assertThat(e.getMessage()).isEqualTo("LinkType not supported by this factory. linkType=LinkType(FOO)"); throw e; } }
public Link<?> constructLink( final Supplier<InterledgerAddress> operatorAddressSupplier, final LinkSettings linkSettings ) { Objects.requireNonNull(operatorAddressSupplier, "operatorAddressSupplier must not be null"); Objects.requireNonNull(linkSettings, "linkSettings must not be null"); if (!this.supports(linkSettings.getLinkType())) { throw new LinkException( String.format("LinkType not supported by this factory. linkType=%s", linkSettings.getLinkType()), LinkId.of("n/a") ); } if (lazyPingLoopbackLink != null) { return lazyPingLoopbackLink; } else { synchronized (this) { if (lazyPingLoopbackLink == null) { lazyPingLoopbackLink = new PingLoopbackLink(operatorAddressSupplier, linkSettings); } return lazyPingLoopbackLink; } } }
PingLoopbackLinkFactory implements LinkFactory { public Link<?> constructLink( final Supplier<InterledgerAddress> operatorAddressSupplier, final LinkSettings linkSettings ) { Objects.requireNonNull(operatorAddressSupplier, "operatorAddressSupplier must not be null"); Objects.requireNonNull(linkSettings, "linkSettings must not be null"); if (!this.supports(linkSettings.getLinkType())) { throw new LinkException( String.format("LinkType not supported by this factory. linkType=%s", linkSettings.getLinkType()), LinkId.of("n/a") ); } if (lazyPingLoopbackLink != null) { return lazyPingLoopbackLink; } else { synchronized (this) { if (lazyPingLoopbackLink == null) { lazyPingLoopbackLink = new PingLoopbackLink(operatorAddressSupplier, linkSettings); } return lazyPingLoopbackLink; } } } }
PingLoopbackLinkFactory implements LinkFactory { public Link<?> constructLink( final Supplier<InterledgerAddress> operatorAddressSupplier, final LinkSettings linkSettings ) { Objects.requireNonNull(operatorAddressSupplier, "operatorAddressSupplier must not be null"); Objects.requireNonNull(linkSettings, "linkSettings must not be null"); if (!this.supports(linkSettings.getLinkType())) { throw new LinkException( String.format("LinkType not supported by this factory. linkType=%s", linkSettings.getLinkType()), LinkId.of("n/a") ); } if (lazyPingLoopbackLink != null) { return lazyPingLoopbackLink; } else { synchronized (this) { if (lazyPingLoopbackLink == null) { lazyPingLoopbackLink = new PingLoopbackLink(operatorAddressSupplier, linkSettings); } return lazyPingLoopbackLink; } } }  }
PingLoopbackLinkFactory implements LinkFactory { public Link<?> constructLink( final Supplier<InterledgerAddress> operatorAddressSupplier, final LinkSettings linkSettings ) { Objects.requireNonNull(operatorAddressSupplier, "operatorAddressSupplier must not be null"); Objects.requireNonNull(linkSettings, "linkSettings must not be null"); if (!this.supports(linkSettings.getLinkType())) { throw new LinkException( String.format("LinkType not supported by this factory. linkType=%s", linkSettings.getLinkType()), LinkId.of("n/a") ); } if (lazyPingLoopbackLink != null) { return lazyPingLoopbackLink; } else { synchronized (this) { if (lazyPingLoopbackLink == null) { lazyPingLoopbackLink = new PingLoopbackLink(operatorAddressSupplier, linkSettings); } return lazyPingLoopbackLink; } } }  Link<?> constructLink(
      final Supplier<InterledgerAddress> operatorAddressSupplier, final LinkSettings linkSettings
  ); @Override boolean supports(LinkType linkType); }
PingLoopbackLinkFactory implements LinkFactory { public Link<?> constructLink( final Supplier<InterledgerAddress> operatorAddressSupplier, final LinkSettings linkSettings ) { Objects.requireNonNull(operatorAddressSupplier, "operatorAddressSupplier must not be null"); Objects.requireNonNull(linkSettings, "linkSettings must not be null"); if (!this.supports(linkSettings.getLinkType())) { throw new LinkException( String.format("LinkType not supported by this factory. linkType=%s", linkSettings.getLinkType()), LinkId.of("n/a") ); } if (lazyPingLoopbackLink != null) { return lazyPingLoopbackLink; } else { synchronized (this) { if (lazyPingLoopbackLink == null) { lazyPingLoopbackLink = new PingLoopbackLink(operatorAddressSupplier, linkSettings); } return lazyPingLoopbackLink; } } }  Link<?> constructLink(
      final Supplier<InterledgerAddress> operatorAddressSupplier, final LinkSettings linkSettings
  ); @Override boolean supports(LinkType linkType);  }