RobotsURIBuilder { @Nonnull public RobotsURIBuilder fromURL(@Nonnull URL url) { checkNotNull(url, "uri is null"); return from(url.getProtocol(), Optional.fromNullable(url.getUserInfo()), url.getHost(), url.getPort() >= 0 ? Optional.of(url.getPort()) : Optional.<Integer>absent()); }  @Nonnull RobotsURIBuilder withScheme(@Nonnull String scheme); @Nonnull RobotsURIBuilder withUserInfo(@Nonnull String userInfo); @Nonnull RobotsURIBuilder withHost(@Nonnull String host); @Nonnull RobotsURIBuilder withPort(int port); @Nonnull RobotsURIBuilder fromUriString(@Nonnull String uriString); @Nonnull RobotsURIBuilder fromUri(@Nonnull URI uri); @Nonnull RobotsURIBuilder fromURL(@Nonnull URL url); @Nonnull URI build();  }
@Test(expected = NullPointerException.class) public void givenNullURL_whenFromURL_thenThrowsNPE() { builder.fromURL(null); }