use of org.springframework.core.ResolvableType in project spring-boot by spring-projects.
the class JsonComponentModule method addSerializerWithDeducedType.
@SuppressWarnings({ "unchecked" })
private <T> void addSerializerWithDeducedType(JsonSerializer<T> serializer) {
ResolvableType type = ResolvableType.forClass(JsonSerializer.class, serializer.getClass());
addSerializer((Class<T>) type.resolveGeneric(), serializer);
}
use of org.springframework.core.ResolvableType in project spring-boot by spring-projects.
the class NoSuchBeanDefinitionFailureAnalyzer method extractBeanType.
private Class<?> extractBeanType(ResolvableType resolvableType) {
ResolvableType collectionType = resolvableType.asCollection();
if (!collectionType.equals(ResolvableType.NONE)) {
return collectionType.getGeneric(0).getRawClass();
}
ResolvableType mapType = resolvableType.asMap();
if (!mapType.equals(ResolvableType.NONE)) {
return mapType.getGeneric(1).getRawClass();
}
return resolvableType.getRawClass();
}
use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.
the class WebFluxConfigurationSupportTests method assertHasMessageReader.
private void assertHasMessageReader(List<HttpMessageReader<?>> readers, Class<?> clazz, MediaType mediaType) {
ResolvableType type = ResolvableType.forClass(clazz);
assertTrue(readers.stream().anyMatch(c -> mediaType == null || c.canRead(type, mediaType)));
}
use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.
the class WebFluxConfigurationSupportTests method assertHasMessageWriter.
private void assertHasMessageWriter(List<HttpMessageWriter<?>> writers, Class<?> clazz, MediaType mediaType) {
ResolvableType type = ResolvableType.forClass(clazz);
assertTrue(writers.stream().anyMatch(c -> mediaType == null || c.canWrite(type, mediaType)));
}
use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.
the class SseIntegrationTests method sseAsEvent.
@Test
public void sseAsEvent() throws Exception {
ResolvableType type = forClassWithGenerics(ServerSentEvent.class, String.class);
Flux<ServerSentEvent<String>> result = this.webClient.get().uri("/event").accept(TEXT_EVENT_STREAM).exchange().flatMap(response -> response.body(toFlux(type)));
StepVerifier.create(result).consumeNextWith(event -> {
assertEquals("0", event.id().get());
assertEquals("foo", event.data().get());
assertEquals("bar", event.comment().get());
assertFalse(event.event().isPresent());
assertFalse(event.retry().isPresent());
}).consumeNextWith(event -> {
assertEquals("1", event.id().get());
assertEquals("foo", event.data().get());
assertEquals("bar", event.comment().get());
assertFalse(event.event().isPresent());
assertFalse(event.retry().isPresent());
}).thenCancel().verify(Duration.ofSeconds(5L));
}
Aggregations