use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.
the class CandidateComponentsIndex method parseIndex.
private static MultiValueMap<String, String> parseIndex(List<Properties> content) {
MultiValueMap<String, String> index = new LinkedMultiValueMap<>();
for (Properties entry : content) {
for (Map.Entry<Object, Object> entries : entry.entrySet()) {
String type = (String) entries.getKey();
String[] stereotypes = ((String) entries.getValue()).split(",");
for (String stereotype : stereotypes) {
index.add(stereotype, type);
}
}
}
return index;
}
use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.
the class AnnotationMetadataReadingVisitor method getAllAnnotationAttributes.
@Override
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) {
MultiValueMap<String, Object> allAttributes = new LinkedMultiValueMap<>();
List<AnnotationAttributes> attributes = this.attributesMap.get(annotationName);
if (attributes == null) {
return null;
}
for (AnnotationAttributes raw : attributes) {
for (Map.Entry<String, Object> entry : AnnotationReadingVisitorUtils.convertClassValues("class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString).entrySet()) {
allAttributes.add(entry.getKey(), entry.getValue());
}
}
return allAttributes;
}
use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.
the class MapToMapConverterTests method mapToMultiValueMap.
@Test
@SuppressWarnings("unchecked")
public void mapToMultiValueMap() throws Exception {
DefaultConversionService.addDefaultConverters(conversionService);
Map<String, Integer> source = new HashMap<>();
source.put("a", 1);
source.put("b", 2);
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("multiValueMapTarget"));
MultiValueMap<String, String> converted = (MultiValueMap<String, String>) conversionService.convert(source, targetType);
assertThat(converted.size(), equalTo(2));
assertThat(converted.get("a"), equalTo(Arrays.asList("1")));
assertThat(converted.get("b"), equalTo(Arrays.asList("2")));
}
use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.
the class AsyncRestTemplateIntegrationTests method multipart.
@Test
public void multipart() throws Exception {
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>();
parts.add("name 1", "value 1");
parts.add("name 2", "value 2+1");
parts.add("name 2", "value 2+2");
Resource logo = new ClassPathResource("/org/springframework/http/converter/logo.jpg");
parts.add("logo", logo);
HttpEntity<MultiValueMap<String, Object>> requestBody = new HttpEntity<>(parts);
Future<URI> future = template.postForLocation(baseUrl + "/multipart", requestBody);
future.get();
}
use of org.springframework.util.MultiValueMap in project spring-framework by spring-projects.
the class RequestParamMapMethodArgumentResolverTests method resolveMultiValueMapArgument.
@Test
public void resolveMultiValueMapArgument() throws Exception {
MethodParameter param = this.testMethod.annotPresent(RequestParam.class).arg(MultiValueMap.class);
ServerWebExchange exchange = MockServerHttpRequest.get("/path?foo=bar&foo=baz").toExchange();
Object result = resolve(param, exchange);
assertTrue(result instanceof MultiValueMap);
assertEquals(Collections.singletonMap("foo", Arrays.asList("bar", "baz")), result);
}
Aggregations