File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed
spring-data-relational/src
main/java/org/springframework/data/relational/core/mapping/event
test/java/org/springframework/data/relational/core/mapping/event Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 1515 */
1616package org .springframework .data .relational .core .mapping .event ;
1717
18+ import org .springframework .core .ResolvableType ;
19+ import org .springframework .core .ResolvableTypeProvider ;
1820import org .springframework .lang .Nullable ;
1921
2022/**
2527 * @author Mark Paluch
2628 * @author Jens Schauder
2729 */
28- public interface RelationalEvent <E > {
30+ public interface RelationalEvent <E > extends ResolvableTypeProvider {
2931
3032 /**
3133 * @return the entity to which this event refers. Might be {@literal null}.
@@ -38,4 +40,9 @@ public interface RelationalEvent<E> {
3840 * @since 2.0
3941 */
4042 Class <E > getType ();
43+
44+ @ Override
45+ default ResolvableType getResolvableType () {
46+ return ResolvableType .forClassWithGenerics (getClass (), getType ());
47+ }
4148}
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2023 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package org .springframework .data .relational .core .mapping .event ;
17+
18+ import static org .assertj .core .api .AssertionsForClassTypes .*;
19+
20+ import org .junit .jupiter .api .Test ;
21+ import org .springframework .core .ResolvableType ;
22+
23+ /**
24+ * Unit tests for {@link RelationalEvent}.
25+ *
26+ * @author Mark Paluch
27+ */
28+ class RelationalEventUnitTests {
29+
30+ @ Test // GH-1539
31+ void shouldReportCorrectGenericType () {
32+ assertThat (new BeforeConvertEvent <>(new MyAggregate ()).getResolvableType ())
33+ .isEqualTo (ResolvableType .forClassWithGenerics (BeforeConvertEvent .class , MyAggregate .class ));
34+ }
35+
36+ static class MyAggregate {}
37+ }
You can’t perform that action at this time.
0 commit comments