Skip to content
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

Merged

Conversation

Quinn-With-Two-Ns
Copy link
Contributor

Fix type assertion for primitive type since we can't rely on a strict equality in that case.

Copy link
Contributor

@cretz cretz left a 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

Comment on lines 30 to 36
static Type wrapTypeIfPrimitive(Type type) {
Class<?> clazz = primitiveWrapperTypeMap.get(type);
if (clazz != null) {
return clazz;
}
return type;
}
Copy link
Contributor

@cretz cretz Dec 5, 2024

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:

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit cdd5e93 into nexus-rpc:main Dec 5, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants