@Override public String toString() { return StringUtils.collectionToCommaDelimitedString(this.converters); } }
/** * Set the set of allowed {@link HttpMethod HTTP methods}, * as specified by the {@code Allow} header. */ public void setAllow(Set<HttpMethod> allowedMethods) { set(ALLOW, StringUtils.collectionToCommaDelimitedString(allowedMethods)); }
/** * Set the (new) value of the {@code Access-Control-Allow-Methods} response header. */ public void setAccessControlAllowMethods(List<HttpMethod> allowedMethods) { set(ACCESS_CONTROL_ALLOW_METHODS, StringUtils.collectionToCommaDelimitedString(allowedMethods)); }
@Override public String toString() { return StringUtils.collectionToCommaDelimitedString(this.converters); } }
/** * Create a new {@code NoUniqueBeanDefinitionException}. * @param type required type of the non-unique bean * @param beanNamesFound the names of all matching beans (as a Collection) * @since 5.1 */ public NoUniqueBeanDefinitionException(ResolvableType type, Collection<String> beanNamesFound) { super(type, "expected single matching bean but found " + beanNamesFound.size() + ": " + StringUtils.collectionToCommaDelimitedString(beanNamesFound)); this.numberOfBeansFound = beanNamesFound.size(); this.beanNamesFound = beanNamesFound; }
/** * Create a new {@code NoUniqueBeanDefinitionException}. * @param type required type of the non-unique bean * @param beanNamesFound the names of all matching beans (as a Collection) */ public NoUniqueBeanDefinitionException(Class<?> type, Collection<String> beanNamesFound) { super(type, "expected single matching bean but found " + beanNamesFound.size() + ": " + StringUtils.collectionToCommaDelimitedString(beanNamesFound)); this.numberOfBeansFound = beanNamesFound.size(); this.beanNamesFound = beanNamesFound; }
/** * Set the (new) value of the {@code Access-Control-Allow-Methods} response header. */ public void setAccessControlAllowMethods(List<HttpMethod> allowedMethods) { set(ACCESS_CONTROL_ALLOW_METHODS, StringUtils.collectionToCommaDelimitedString(allowedMethods)); }
/** * Set the set of allowed {@link HttpMethod HTTP methods}, * as specified by the {@code Allow} header. */ public void setAllow(Set<HttpMethod> allowedMethods) { set(ALLOW, StringUtils.collectionToCommaDelimitedString(allowedMethods)); }
/** * Generate a default cache name for the specified {@link Method}. * @param method the annotated method * @return the default cache name, according to JSR-107 */ protected String generateDefaultCacheName(Method method) { Class<?>[] parameterTypes = method.getParameterTypes(); List<String> parameters = new ArrayList<>(parameterTypes.length); for (Class<?> parameterType : parameterTypes) { parameters.add(parameterType.getName()); } StringBuilder sb = new StringBuilder(method.getDeclaringClass().getName()); sb.append(".").append(method.getName()); sb.append("(").append(StringUtils.collectionToCommaDelimitedString(parameters)).append(")"); return sb.toString(); }
/** * Create a new {@code NoUniqueBeanDefinitionException}. * @param type required type of the non-unique bean * @param beanNamesFound the names of all matching beans (as a Collection) * @since 5.1 */ public NoUniqueBeanDefinitionException(ResolvableType type, Collection<String> beanNamesFound) { super(type, "expected single matching bean but found " + beanNamesFound.size() + ": " + StringUtils.collectionToCommaDelimitedString(beanNamesFound)); this.numberOfBeansFound = beanNamesFound.size(); this.beanNamesFound = beanNamesFound; }
/** * Create a new {@code NoUniqueBeanDefinitionException}. * @param type required type of the non-unique bean * @param beanNamesFound the names of all matching beans (as a Collection) */ public NoUniqueBeanDefinitionException(Class<?> type, Collection<String> beanNamesFound) { super(type, "expected single matching bean but found " + beanNamesFound.size() + ": " + StringUtils.collectionToCommaDelimitedString(beanNamesFound)); this.numberOfBeansFound = beanNamesFound.size(); this.beanNamesFound = beanNamesFound; }
@Override public String toString() { StringBuilder sb = new StringBuilder(ObjectUtils.identityToString(this)); sb.append(": defining beans ["); sb.append(StringUtils.collectionToCommaDelimitedString(this.beanDefinitionNames)); sb.append("]; "); BeanFactory parent = getParentBeanFactory(); if (parent == null) { sb.append("root of factory hierarchy"); } else { sb.append("parent: ").append(ObjectUtils.identityToString(parent)); } return sb.toString(); }
/** * This implementation first checks to see if the name specified is the special * {@linkplain #setNonOptionArgsPropertyName(String) "non-option arguments" property}, * and if so delegates to the abstract {@link #getNonOptionArgs()} method. If so * and the collection of non-option arguments is empty, this method returns {@code * null}. If not empty, it returns a comma-separated String of all non-option * arguments. Otherwise delegates to and returns the result of the abstract {@link * #getOptionValues(String)} method. */ @Override @Nullable public final String getProperty(String name) { if (this.nonOptionArgsPropertyName.equals(name)) { Collection<String> nonOptionArguments = this.getNonOptionArgs(); if (nonOptionArguments.isEmpty()) { return null; } else { return StringUtils.collectionToCommaDelimitedString(nonOptionArguments); } } Collection<String> optionValues = this.getOptionValues(name); if (optionValues == null) { return null; } else { return StringUtils.collectionToCommaDelimitedString(optionValues); } }
@Override public Class<?> getType(String name) throws NoSuchBeanDefinitionException { String beanName = BeanFactoryUtils.transformedBeanName(name); Object bean = this.beans.get(beanName); if (bean == null) { throw new NoSuchBeanDefinitionException(beanName, "Defined beans are [" + StringUtils.collectionToCommaDelimitedString(this.beans.keySet()) + "]"); } if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) { // If it's a FactoryBean, we want to look at what it creates, not the factory class. return ((FactoryBean<?>) bean).getObjectType(); } return bean.getClass(); }
private static <B extends HttpSecurityBuilder<B>> OAuth2AuthorizedClientRepository getAuthorizedClientRepositoryBean(B builder) { Map<String, OAuth2AuthorizedClientRepository> authorizedClientRepositoryMap = BeanFactoryUtils.beansOfTypeIncludingAncestors( builder.getSharedObject(ApplicationContext.class), OAuth2AuthorizedClientRepository.class); if (authorizedClientRepositoryMap.size() > 1) { throw new NoUniqueBeanDefinitionException(OAuth2AuthorizedClientRepository.class, authorizedClientRepositoryMap.size(), "Expected single matching bean of type '" + OAuth2AuthorizedClientRepository.class.getName() + "' but found " + authorizedClientRepositoryMap.size() + ": " + StringUtils.collectionToCommaDelimitedString(authorizedClientRepositoryMap.keySet())); } return (!authorizedClientRepositoryMap.isEmpty() ? authorizedClientRepositoryMap.values().iterator().next() : null); }
private static <B extends HttpSecurityBuilder<B>> OAuth2AuthorizedClientService getAuthorizedClientServiceBean(B builder) { Map<String, OAuth2AuthorizedClientService> authorizedClientServiceMap = BeanFactoryUtils.beansOfTypeIncludingAncestors( builder.getSharedObject(ApplicationContext.class), OAuth2AuthorizedClientService.class); if (authorizedClientServiceMap.size() > 1) { throw new NoUniqueBeanDefinitionException(OAuth2AuthorizedClientService.class, authorizedClientServiceMap.size(), "Expected single matching bean of type '" + OAuth2AuthorizedClientService.class.getName() + "' but found " + authorizedClientServiceMap.size() + ": " + StringUtils.collectionToCommaDelimitedString(authorizedClientServiceMap.keySet())); } return (!authorizedClientServiceMap.isEmpty() ? authorizedClientServiceMap.values().iterator().next() : null); } }
private void initAllowHeader() { Collection<String> allowedMethods; if (this.supportedMethods == null) { allowedMethods = new ArrayList<>(HttpMethod.values().length - 1); for (HttpMethod method : HttpMethod.values()) { if (method != HttpMethod.TRACE) { allowedMethods.add(method.name()); } } } else if (this.supportedMethods.contains(HttpMethod.OPTIONS.name())) { allowedMethods = this.supportedMethods; } else { allowedMethods = new ArrayList<>(this.supportedMethods); allowedMethods.add(HttpMethod.OPTIONS.name()); } this.allowHeader = StringUtils.collectionToCommaDelimitedString(allowedMethods); }
private String getAutoApproveScopes(ClientDetails clientDetails) { if (clientDetails.isAutoApprove("true")) { return "true"; // all scopes autoapproved } Set<String> scopes = new HashSet<String>(); for (String scope : clientDetails.getScope()) { if (clientDetails.isAutoApprove(scope)) { scopes.add(scope); } } return StringUtils.collectionToCommaDelimitedString(scopes); }
@Override public Object getBean(String name) throws BeansException { String beanName = BeanFactoryUtils.transformedBeanName(name); Object bean = this.beans.get(beanName); if (bean == null) { throw new NoSuchBeanDefinitionException(beanName, "Defined beans are [" + StringUtils.collectionToCommaDelimitedString(this.beans.keySet()) + "]"); } // Don't let calling code try to dereference the // bean factory if the bean isn't a factory if (BeanFactoryUtils.isFactoryDereference(name) && !(bean instanceof FactoryBean)) { throw new BeanIsNotAFactoryException(beanName, bean.getClass()); } if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) { try { Object exposedObject = ((FactoryBean<?>) bean).getObject(); if (exposedObject == null) { throw new BeanCreationException(beanName, "FactoryBean exposed null object"); } return exposedObject; } catch (Exception ex) { throw new BeanCreationException(beanName, "FactoryBean threw exception on object creation", ex); } } else { return bean; } }
@Override public Mono<Void> execute(URI url, HttpHeaders requestHeaders, WebSocketHandler handler) { return getHttpClient() .headers(nettyHeaders -> setNettyHeaders(requestHeaders, nettyHeaders)) .websocket(StringUtils.collectionToCommaDelimitedString(handler.getSubProtocols())) .uri(url.toString()) .handle((inbound, outbound) -> { HttpHeaders responseHeaders = toHttpHeaders(inbound); String protocol = responseHeaders.getFirst("Sec-WebSocket-Protocol"); HandshakeInfo info = new HandshakeInfo(url, responseHeaders, Mono.empty(), protocol); NettyDataBufferFactory factory = new NettyDataBufferFactory(outbound.alloc()); WebSocketSession session = new ReactorNettyWebSocketSession(inbound, outbound, info, factory); if (logger.isDebugEnabled()) { logger.debug("Started session '" + session.getId() + "' for " + url); } return handler.handle(session); }) .doOnRequest(n -> { if (logger.isDebugEnabled()) { logger.debug("Connecting to " + url); } }) .next(); }