-
Notifications
You must be signed in to change notification settings - Fork 176
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
[Feature Request]Suffix appending behind of all class name #165
Comments
Hi @Hades32 I think making the first letter lowercase is better, what do you think? could you send a pull request to fix this? thanks
|
@Hades32 Try to select an annotation or use the suffix function:
If there any problem, Please contact us, thanks. |
@wuseal both solution have issues: annotations make the code less portable and a suffix breaks compatibility with the actual json which is not under my control. I'd prefer if there were an extension "Suffix after every class name". Then I'd just enter "Dto" and all the classes would be Dtos |
@Hades32, Yeah, An extension could implement your request feature, And the implemented code may be like this in extension instance class : override fun intercept(kotlinDataClass: KotlinDataClass): KotlinDataClass {
val standTypes = listOf<String>("Int", "Double", "Long", "String", "Boolean")
val originName = kotlinDataClass.name
val newPropertyTypes =
kotlinDataClass.properties.map { if (standTypes.contains(it.type)) it.type else it.type + "Dto" }
val newProperties = kotlinDataClass.properties.mapIndexed { index, property ->
val newType = newPropertyTypes[index]
property.copy(type = newType)
}
return kotlinDataClass.copy(name = originName + "Dto", properties = newProperties)
} And If you interested in this, A PR for this feature will heighly appreciated. data class BlubberDto(
val Master: MasterDto
)
data class MasterDto(
val a: Int
) |
I have added this function,You can use it in later new versions. |
Fixed in 3.3.0-EAP-2 |
Example json:
When using inner classes will generate a inner class and a field named
Mater
.Easiest fix would be to append some postfix like
...Data
.The text was updated successfully, but these errors were encountered: