/** * Replace any hostname requirements with the supplied hostname. * * @param hostname the hostname to use as a requirement * @return {@code this}. */ @NonNull public URIRequirementBuilder withHostname(@CheckForNull String hostname) { return withHostnamePort(hostname, -1); }
static List<DomainRequirement> gitLabConnectionRequirements(String connectioName) { URIRequirementBuilder builder = URIRequirementBuilder.create(); try { URL connectionURL = new URL(gitLabConnection(connectioName).getUrl()); builder.withHostnamePort(connectionURL.getHost(), connectionURL.getPort()); } catch (Exception ignored) { LOGGER.fine("ignoring invalid gitlab-connection: " + connectioName); } return builder.build(); }
/** * Replace any hostname requirements with the supplied hostname. * * @param hostname the hostname to use as a requirement * @return {@code this}. */ @NonNull public URIRequirementBuilder withHostname(@CheckForNull String hostname) { return withHostnamePort(hostname, -1); }
/** * 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; }