-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix type assertion for primitive type #22
Fix type assertion for primitive type #22
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately Java reflection doesn't have this utility, so this LGTM, only minor suggestions
static Type wrapTypeIfPrimitive(Type type) { | ||
Class<?> clazz = primitiveWrapperTypeMap.get(type); | ||
if (clazz != null) { | ||
return clazz; | ||
} | ||
return type; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can make the map value type a Type
too and do:
static Type wrapTypeIfPrimitive(Type type) { | |
Class<?> clazz = primitiveWrapperTypeMap.get(type); | |
if (clazz != null) { | |
return clazz; | |
} | |
return type; | |
} | |
static Type wrapTypeIfPrimitive(Type type) { | |
primitiveWrapperTypeMap.getOrDefault(type, type); | |
} |
But it's pedantic. Could also just bury the switch
in here which may be cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Fix type assertion for primitive type since we can't rely on a strict equality in that case.