/** * Replace any scheme requirements with the supplied scheme. * * @param scheme the scheme to use as a requirement * @return {@code this}. */ @NonNull public URIRequirementBuilder withScheme(@CheckForNull String scheme) { withoutScheme(); if (scheme != null) { requirements.add(new SchemeRequirement(scheme)); } return this; }
/** * Replace any scheme requirements with the supplied scheme. * * @param scheme the scheme to use as a requirement * @return {@code this}. */ @NonNull public URIRequirementBuilder withScheme(@CheckForNull String scheme) { withoutScheme(); if (scheme != null) { requirements.add(new SchemeRequirement(scheme)); } return this; }
/** * Replaces the requirements with those of the supplied URI. * * @param uri the URI. * @return {@code this}. */ @NonNull public URIRequirementBuilder withUri(@CheckForNull String uri) { if (uri != null) { try { URI u = new URI(uri); withScheme(u.getScheme()); withHostnamePort(u.getHost(), u.getPort()); withPath(u.getRawPath()); } catch (URISyntaxException e) { withoutScheme().withoutHostname().withoutHostnamePort(); } } return this; }
/** * Replaces the requirements with those of the supplied URI. * * @param uri the URI. * @return {@code this}. */ @NonNull public URIRequirementBuilder withUri(@CheckForNull String uri) { if (uri != null) { try { URI u = new URI(uri); withScheme(u.getScheme()); withHostnamePort(u.getHost(), u.getPort()); withPath(u.getRawPath()); } catch (URISyntaxException e) { withoutScheme().withoutHostname().withoutHostnamePort(); } } return this; }