use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.
the class GenericApplicationListenerAdapterTests method genericListenerStrictTypeTypeErasure.
// Demonstrates we can't inject that event because the generic type is lost
@Test
public void genericListenerStrictTypeTypeErasure() {
GenericTestEvent<String> stringEvent = createGenericTestEvent("test");
ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
supportsEventType(false, StringEventListener.class, eventType);
}
use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.
the class GenericApplicationListenerAdapterTests method genericListenerStrictTypeAndResolvableTypeProvider.
// or if the event provides its precise type
@Test
public void genericListenerStrictTypeAndResolvableTypeProvider() {
ResolvableType eventType = new SmartGenericTestEvent<>(this, "foo").getResolvableType();
supportsEventType(true, StringEventListener.class, eventType);
}
use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.
the class GenericApplicationListenerAdapterTests method genericListenerRawTypeTypeErasure.
// Demonstrates we cant inject that event because the listener has a raw type
@Test
public void genericListenerRawTypeTypeErasure() {
GenericTestEvent<String> stringEvent = createGenericTestEvent("test");
ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
supportsEventType(true, RawApplicationListener.class, eventType);
}
use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.
the class GenericApplicationListenerAdapterTests method genericListenerStrictTypeEventSubTypeNotMatching.
@Test
public void genericListenerStrictTypeEventSubTypeNotMatching() {
LongEvent stringEvent = new LongEvent(this, 123L);
ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
supportsEventType(false, StringEventListener.class, eventType);
}
use of org.springframework.core.ResolvableType in project spring-framework by spring-projects.
the class GenericApplicationListenerAdapterTests method genericListenerStrictTypeEventSubType.
// Demonstrates it works if we actually use the subtype
@Test
public void genericListenerStrictTypeEventSubType() {
StringEvent stringEvent = new StringEvent(this, "test");
ResolvableType eventType = ResolvableType.forType(stringEvent.getClass());
supportsEventType(true, StringEventListener.class, eventType);
}
Aggregations