private String collectionToString(Collection<? extends CharSequence> collection) { return StringUtils.collectionToDelimitedString(collection, separator); } }
/** * Convert a {@code Collection} into a delimited {@code String} (e.g., CSV). * <p>Useful for {@code toString()} implementations. * @param coll the {@code Collection} to convert (potentially {@code null} or empty) * @return the delimited {@code String} */ public static String collectionToCommaDelimitedString(@Nullable Collection<?> coll) { return collectionToDelimitedString(coll, ","); }
/** * Convert a {@code Collection} into a delimited {@code String} (e.g. CSV). * <p>Useful for {@code toString()} implementations. * @param coll the {@code Collection} to convert (potentially {@code null} or empty) * @param delim the delimiter to use (typically a ",") * @return the delimited {@code String} */ public static String collectionToDelimitedString(@Nullable Collection<?> coll, String delim) { return collectionToDelimitedString(coll, delim, "", ""); }
/** * Formats a set of string values into a format appropriate for sending as a single-valued form value. * * @param value The value of the parameter. * @return The value formatted for form submission etc, or null if the input is empty */ public static String formatParameterList(Collection<String> value) { return value == null ? null : StringUtils.collectionToDelimitedString(value, " "); }
/** * Convert a {@code Collection} into a delimited {@code String} (e.g. CSV). * <p>Useful for {@code toString()} implementations. * @param coll the {@code Collection} to convert (potentially {@code null} or empty) * @param delim the delimiter to use (typically a ",") * @return the delimited {@code String} */ public static String collectionToDelimitedString(@Nullable Collection<?> coll, String delim) { return collectionToDelimitedString(coll, delim, "", ""); }
/** * Convert a {@code Collection} into a delimited {@code String} (e.g., CSV). * <p>Useful for {@code toString()} implementations. * @param coll the {@code Collection} to convert (potentially {@code null} or empty) * @return the delimited {@code String} */ public static String collectionToCommaDelimitedString(@Nullable Collection<?> coll) { return collectionToDelimitedString(coll, ","); }
/** * Add the given headers to the given HTTP connection. * @param connection the connection to add the headers to * @param headers the headers to add */ static void addHeaders(HttpURLConnection connection, HttpHeaders headers) { headers.forEach((headerName, headerValues) -> { if (HttpHeaders.COOKIE.equalsIgnoreCase(headerName)) { // RFC 6265 String headerValue = StringUtils.collectionToDelimitedString(headerValues, "; "); connection.setRequestProperty(headerName, headerValue); } else { for (String headerValue : headerValues) { String actualHeaderValue = headerValue != null ? headerValue : ""; connection.addRequestProperty(headerName, actualHeaderValue); } } }); }
private static String computeDependenciesId(List<String> dependencies) { if (ObjectUtils.isEmpty(dependencies)) { return "_none"; } Collections.sort(dependencies); return StringUtils.collectionToDelimitedString(dependencies, " "); }
public String getMessagesAsOneString() { ArrayList<String> sortedMessages = new ArrayList<String>(errorMessages); Collections.sort(sortedMessages); return StringUtils.collectionToDelimitedString(sortedMessages, " "); }
/** * Create new ServletConfigPropertyValues. * @param config the ServletConfig we'll use to take PropertyValues from * @param requiredProperties set of property names we need, where * we can't accept default values * @throws ServletException if any required properties are missing */ public ServletConfigPropertyValues(ServletConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = (!CollectionUtils.isEmpty(requiredProperties) ? new HashSet<>(requiredProperties) : null); Enumeration<String> paramNames = config.getInitParameterNames(); while (paramNames.hasMoreElements()) { String property = paramNames.nextElement(); Object value = config.getInitParameter(property); addPropertyValue(new PropertyValue(property, value)); if (missingProps != null) { missingProps.remove(property); } } // Fail if we are still missing properties. if (!CollectionUtils.isEmpty(missingProps)) { throw new ServletException( "Initialization from ServletConfig for servlet '" + config.getServletName() + "' failed; the following required properties were missing: " + StringUtils.collectionToDelimitedString(missingProps, ", ")); } } }
if (!keys.isEmpty()) { tokens.canonicalName += PROPERTY_KEY_PREFIX + StringUtils.collectionToDelimitedString(keys, PROPERTY_KEY_SUFFIX + PROPERTY_KEY_PREFIX) + PROPERTY_KEY_SUFFIX; tokens.keys = StringUtils.toStringArray(keys);
/** * Create new FilterConfigPropertyValues. * @param config the FilterConfig we'll use to take PropertyValues from * @param requiredProperties set of property names we need, where * we can't accept default values * @throws ServletException if any required properties are missing */ public FilterConfigPropertyValues(FilterConfig config, Set<String> requiredProperties) throws ServletException { Set<String> missingProps = (!CollectionUtils.isEmpty(requiredProperties) ? new HashSet<>(requiredProperties) : null); Enumeration<String> paramNames = config.getInitParameterNames(); while (paramNames.hasMoreElements()) { String property = paramNames.nextElement(); Object value = config.getInitParameter(property); addPropertyValue(new PropertyValue(property, value)); if (missingProps != null) { missingProps.remove(property); } } // Fail if we are still missing properties. if (!CollectionUtils.isEmpty(missingProps)) { throw new ServletException( "Initialization from FilterConfig for filter '" + config.getFilterName() + "' failed; the following required properties were missing: " + StringUtils.collectionToDelimitedString(missingProps, ", ")); } } }
/** * Add the given headers to the given HTTP request. * @param httpRequest the request to add the headers to * @param headers the headers to add */ static void addHeaders(HttpUriRequest httpRequest, HttpHeaders headers) { headers.forEach((headerName, headerValues) -> { if (HttpHeaders.COOKIE.equalsIgnoreCase(headerName)) { // RFC 6265 String headerValue = StringUtils.collectionToDelimitedString(headerValues, "; "); httpRequest.addHeader(headerName, headerValue); } else if (!HTTP.CONTENT_LEN.equalsIgnoreCase(headerName) && !HTTP.TRANSFER_ENCODING.equalsIgnoreCase(headerName)) { for (String headerValue : headerValues) { httpRequest.addHeader(headerName, headerValue); } } }); }
StringUtils.collectionToDelimitedString(this.boundObjects.keySet(), ",") + "]");
private String getPortsDescription() { List<UndertowWebServer.Port> ports = getActualPorts(); if (!ports.isEmpty()) { return StringUtils.collectionToDelimitedString(ports, " "); } return "unknown"; }
private String join(Iterable<Term> terms) { List<String> result = new ArrayList<String>(); for (Term term : terms) { if (term != null) { result.add(term.getFormatted()); } } return StringUtils.collectionToDelimitedString(result, " "); } }
private String getPortsDescription() { List<Port> ports = getActualPorts(); if (!ports.isEmpty()) { return StringUtils.collectionToDelimitedString(ports, " "); } return "unknown"; }
@Override public String getWarning(BeanDefinitionRegistry registry) { Set<String> scannedPackages = getComponentScanningPackages(registry); List<String> problematicPackages = getProblematicPackages(scannedPackages); if (problematicPackages.isEmpty()) { return null; } return "Your ApplicationContext is unlikely to " + "start due to a @ComponentScan of " + StringUtils.collectionToDelimitedString(problematicPackages, ", ") + "."; }
StringUtils.collectionToDelimitedString(this.boundObjects.keySet(), ",") + "]");
private static BodyInserters.FormInserter<String> body(OAuth2ClientCredentialsGrantRequest authorizationGrantRequest) { ClientRegistration clientRegistration = authorizationGrantRequest.getClientRegistration(); BodyInserters.FormInserter<String> body = BodyInserters .fromFormData(OAuth2ParameterNames.GRANT_TYPE, authorizationGrantRequest.getGrantType().getValue()); Set<String> scopes = clientRegistration.getScopes(); if (!CollectionUtils.isEmpty(scopes)) { String scope = StringUtils.collectionToDelimitedString(scopes, " "); body.with(OAuth2ParameterNames.SCOPE, scope); } if (ClientAuthenticationMethod.POST.equals(clientRegistration.getClientAuthenticationMethod())) { body.with(OAuth2ParameterNames.CLIENT_ID, clientRegistration.getClientId()); body.with(OAuth2ParameterNames.CLIENT_SECRET, clientRegistration.getClientSecret()); } return body; }