/** * @param host The Discovery server host name */ public void setHost(String host) { if (StringUtils.isNotEmpty(host)) { this.host = host; } }
/** * Sets the protocol to use. Default value ({@value io.micronaut.http.ssl.SslConfiguration#DEFAULT_PROTOCOL}). * * @param protocol The protocol */ public void setProtocol(String protocol) { if (!StringUtils.isNotEmpty(protocol)) { this.protocol = protocol; } }
@Override public void setIpAddr(String ipAddr) { if (StringUtils.isNotEmpty(ipAddr)) { this.ipAddr = ipAddr; } }
/** * @param datacenter The datacenter * @return The {@link NodeEntry} instance */ public NodeEntry datacenter(String datacenter) { if (StringUtils.isNotEmpty(datacenter)) { this.datacenter = datacenter; } return this; }
@Override public void setAppGroupName(String appGroupName) { if (StringUtils.isNotEmpty(appGroupName)) { this.appGroupName = appGroupName; } }
@Override public void setVipAddress(String vipAddress) { if (StringUtils.isNotEmpty(vipAddress)) { this.vipAddress = vipAddress; } }
/** * Sets the host to bind to. * @param host The host */ public void setHost(String host) { if (StringUtils.isNotEmpty(host)) { this.host = host; } }
@Override public void setSecureVipAddress(String secureVipAddress) { if (StringUtils.isNotEmpty(secureVipAddress)) { this.secureVipAddress = secureVipAddress; } }
/** * Is the given string a series of digits. * * @param str The string * @return True if it is a series of digits */ public static boolean isDigits(String str) { return isNotEmpty(str) && DIGIT_PATTERN.matcher(str).matches(); }
/** * Checks whether the given name is a valid service identifier. * * @param name The name * @return True if it is */ public static boolean isHyphenatedLowerCase(String name) { return StringUtils.isNotEmpty(name) && SERVICE_ID_REGEX.matcher(name).matches() && Character.isLetter(name.charAt(0)); }
/** * Add an embedded resource with the given reference. * * @param ref The reference * @param resource The resource * @return This JsonError */ public Impl embedded(CharSequence ref, Resource resource) { if (StringUtils.isNotEmpty(ref) && resource != null) { List<Resource> resources = this.embeddedMap.computeIfAbsent(ref, charSequence -> new ArrayList<>()); resources.add(resource); } return (Impl) this; }
/** * Add an embedded resource with the given reference. * * @param ref The reference * @param resourceList The resources * @return This JsonError */ public Impl embedded(CharSequence ref, List<Resource> resourceList) { if (StringUtils.isNotEmpty(ref) && resourceList != null) { List<Resource> resources = this.embeddedMap.computeIfAbsent(ref, charSequence -> new ArrayList<>()); resources.addAll(resourceList); } return (Impl) this; }
/** * Add a link with the given reference. * * @param ref The reference * @param link The link * @return This JsonError */ public Impl link(@Nullable CharSequence ref, @Nullable Link link) { if (StringUtils.isNotEmpty(ref) && link != null) { List<Link> links = this.linkMap.computeIfAbsent(ref, charSequence -> new ArrayList<>()); links.add(link); } return (Impl) this; }
private String computeClientKey(String clientId, String path) { if (StringUtils.isEmpty(clientId)) { return null; } String clientKey = clientId; if (StringUtils.isNotEmpty(path)) { clientKey = clientKey + path; } return clientKey; }
private String resolveUriPath() { URI uri = getUri(); if (StringUtils.isNotEmpty(uri.getScheme())) { try { // obtain just the path uri = new URI(null, null, null, -1, uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (URISyntaxException e) { // ignore } } return uri.toString(); }
@Override public Status status() { if (StringUtils.isNotEmpty(status)) { return Status.valueOf(status.toUpperCase(Locale.ENGLISH)); } return Status.PASSING; } }
/** * Add a link with the given reference. * * @param ref The reference * @param link The link * @return This JsonError */ public Impl link(@Nullable CharSequence ref, @Nullable String link) { if (StringUtils.isNotEmpty(ref) && link != null) { List<Link> links = this.linkMap.computeIfAbsent(ref, charSequence -> new ArrayList<>()); links.add(Link.of(link)); } return (Impl) this; }
/** * Obtain the value of an attribute on the HTTP method. * * @param name The name of the attribute * @return An {@link Optional} value */ default @Nonnull Optional<Object> getAttribute(CharSequence name) { if (StringUtils.isNotEmpty(name)) { return getAttributes().get(name.toString(), Object.class); } return Optional.empty(); }
@Override public Optional<String> getGroup() { String asgName = instanceInfo.getAsgName(); if (StringUtils.isNotEmpty(asgName)) { return Optional.of(asgName); } return ServiceInstance.super.getZone(); }
/** * Resolve the {@link MediaType} for the given file name. Defaults * to text/plain. * * @param filename The file name * @return The {@link MediaType} */ public static MediaType forFilename(String filename) { if (StringUtils.isNotEmpty(filename)) { return forExtension(NameUtils.extension(filename)).orElse(MediaType.TEXT_PLAIN_TYPE); } return MediaType.TEXT_PLAIN_TYPE; }