Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit 39d5276

Browse files
committed
#23 - @DBArray with Set<out XXX> does not work
1 parent 2f1dda0 commit 39d5276

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

src/main/java/io/ebean/querybean/generator/ProcessingContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ String generatedSourcesDir() {
132132
private String typeDef(TypeMirror typeMirror) {
133133
if (typeMirror.getKind() == TypeKind.DECLARED) {
134134
DeclaredType declaredType = (DeclaredType) typeMirror;
135-
return declaredType.asElement().toString();
135+
return Split.trimType(declaredType.asElement().toString());
136136
} else {
137-
return typeMirror.toString();
137+
return Split.trimType(typeMirror.toString());
138138
}
139139
}
140140

src/main/java/io/ebean/querybean/generator/Split.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,14 @@ static String shortName(String className) {
3131
return className.substring(startPos + 1);
3232
}
3333

34+
/**
35+
* Trim "? extends" from a Kotlin "out" collection type.
36+
*/
37+
static String trimType(String fullType) {
38+
if (fullType.startsWith("? ")) {
39+
return fullType.substring(10);
40+
}
41+
return fullType;
42+
}
43+
3444
}

src/test/java/io/ebean/querybean/generator/SplitTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@
88
public class SplitTest {
99

1010
@Test
11-
public void shortName() throws Exception {
11+
public void trimType() {
12+
assertEquals(Split.trimType("com.foo.domain.Customer"), "com.foo.domain.Customer");
13+
assertEquals(Split.trimType("? extends com.foo.domain.Customer"), "com.foo.domain.Customer");
14+
}
1215

16+
@Test
17+
public void shortName() {
1318
assertEquals(Split.shortName("com.foo.domain.Customer"), "Customer");
1419
assertEquals(Split.shortName("Customer"), "Customer");
1520
}
1621

1722
@Test
18-
public void split_normal() throws Exception {
23+
public void split_normal() {
1924

2025
String[] split = Split.split("com.foo.domain.Customer");
2126

@@ -24,7 +29,7 @@ public void split_normal() throws Exception {
2429
}
2530

2631
@Test
27-
public void split_noPackage() throws Exception {
32+
public void split_noPackage() {
2833

2934
String[] split = Split.split("Customer");
3035

0 commit comments

Comments
 (0)