RobotsURIBuilder { @Nonnull public URI build() { if (!host.isPresent()) { throw new IllegalStateException("Required field 'host' is not set."); } if (!scheme.isPresent()) { throw new IllegalStateException("Required field 'scheme' is not set."); } if (!port.isPresent()) { setDefaultPort(); } try { return new URI(scheme.orNull(), userInfo.orNull(), host.orNull(), port.orNull(), PATH, null, null); } catch (URISyntaxException e) { throw new AssertionError(e); } }  @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 = IllegalStateException.class) public void givenHostUnset_whenBuild_thenThrowsISE() { builder.build(); }