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

Update FlowResponseConverterFunctionProvider Type Extension functions toClass() #5201

Merged
merged 4 commits into from
Sep 25, 2023

Conversation

esperar
Copy link
Contributor

@esperar esperar commented Sep 22, 2023

Type of PR

Hello! While reviewing the Kotlin part of Armeria, I noticed that in the FlowResponseConverterFunctionProvider class, there's an extension function for Type used in the createResponseConverterFunction() function of DelegatingResponseConverterFunctionProvider. The toClass() function returns a type of Class<*>?.


In the past, when working with Kotlin, I found it beneficial to define extension functions that return nullable values with names following the toXXXOrNull() pattern. This made the code more understandable for me and my teammates, especially during maintenance.


Since the extension function is defined just below createResponseConverterFunction(), it may lead to questions like "Why use toClass()?.let here?" Adding OrNull to the function name can make the code more readable.


I understand that naming conventions can vary among teams, and it may not be a critical issue. However, if you find the suggestion helpful, I'd appreciate it if you could consider applying the change.


private fun Type.toClassOrNull(): Class<*>? =
    when (this) {
        is ParameterizedType -> this.rawType as Class<*>
        is Class<*> -> this
        else -> null
    }

@CLAassistant
Copy link

CLAassistant commented Sep 22, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

Looks good to me. 👍
By the way, could you write the commit description in English so that others can read it as well?
ChatGPT might help you. 😉

@esperar
Copy link
Contributor Author

esperar commented Sep 22, 2023

I did

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Thanks @esperar for the cleanup 👍

@jrhee17 jrhee17 added this to the 1.26.0 milestone Sep 25, 2023
Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

Looks nicer! ❤️

@minwoox minwoox merged commit 33f1b57 into line:main Sep 25, 2023
@minwoox
Copy link
Contributor

minwoox commented Sep 25, 2023

Thanks a lot, @esperar! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants