Skip to content

Fix Annotations when using JsonB #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ public class Util {
* Parse the raw type potentially handling generic parameters.
*/
public static UType parse(String rawType) {
int pos = rawType.indexOf('<');
var type = trimAnnotations(rawType);
int pos = type.indexOf('<');
if (pos == -1) {
return new UType.Basic(rawType);
return new UType.Basic(type);
} else {
return new UType.Generic(rawType);
return new UType.Generic(type);
}
}

Expand All @@ -30,10 +31,19 @@ public static UType parse(String rawType) {
public static String typeDef(TypeMirror typeMirror) {
if (typeMirror.getKind() == TypeKind.DECLARED) {
DeclaredType declaredType = (DeclaredType) typeMirror;

return declaredType.asElement().toString();
} else {
return typeMirror.toString();
return trimAnnotations(typeMirror.toString());
}
}

static String trimAnnotations(String type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we add a unit test for this trimAnnotations() method

int pos = type.indexOf("@");
if (pos == -1) {
return type;
}
return type.substring(0, pos) + type.substring(type.lastIndexOf(' ') + 1);
}

static String trimPath(String value) {
Expand Down