Skip to content

Commit c9fe237

Browse files
authored
Merge pull request #125 from SentryMan/master
Fix Annotations when using JsonB
2 parents a45a6ce + 9b9eb7c commit c9fe237

File tree

1 file changed

+14
-4
lines changed
  • http-generator-core/src/main/java/io/avaje/http/generator/core

1 file changed

+14
-4
lines changed

http-generator-core/src/main/java/io/avaje/http/generator/core/Util.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ public class Util {
1616
* Parse the raw type potentially handling generic parameters.
1717
*/
1818
public static UType parse(String rawType) {
19-
int pos = rawType.indexOf('<');
19+
var type = trimAnnotations(rawType);
20+
int pos = type.indexOf('<');
2021
if (pos == -1) {
21-
return new UType.Basic(rawType);
22+
return new UType.Basic(type);
2223
} else {
23-
return new UType.Generic(rawType);
24+
return new UType.Generic(type);
2425
}
2526
}
2627

@@ -30,10 +31,19 @@ public static UType parse(String rawType) {
3031
public static String typeDef(TypeMirror typeMirror) {
3132
if (typeMirror.getKind() == TypeKind.DECLARED) {
3233
DeclaredType declaredType = (DeclaredType) typeMirror;
34+
3335
return declaredType.asElement().toString();
3436
} else {
35-
return typeMirror.toString();
37+
return trimAnnotations(typeMirror.toString());
38+
}
39+
}
40+
41+
static String trimAnnotations(String type) {
42+
int pos = type.indexOf("@");
43+
if (pos == -1) {
44+
return type;
3645
}
46+
return type.substring(0, pos) + type.substring(type.lastIndexOf(' ') + 1);
3747
}
3848

3949
static String trimPath(String value) {

0 commit comments

Comments
 (0)