@Test public void constructLink() { LinkSettings linkSettings = LinkSettings.builder() .linkType(PingLoopbackLink.LINK_TYPE) .build(); Link<?> link = pingLoopbackLinkFactory.constructLink(() -> OPERATOR_ADDRESS, linkSettings); link.setLinkId(LINK_ID); assertThat(link.getLinkId()).isEqualTo(LINK_ID); }
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);  }