Skip to content

Instantly share code, notes, and snippets.

@rubenquadros
Last active May 3, 2022 09:06
Show Gist options
  • Save rubenquadros/0a506a5324f893153d111c88a6871924 to your computer and use it in GitHub Desktop.
Save rubenquadros/0a506a5324f893153d111c88a6871924 to your computer and use it in GitHub Desktop.
An extension function on KtClass to see if any param is missing SerializedName annotation
// returns the param if SerializedName annotation is missing
fun KtClass.getMissingAnnotationParam(): KtParameter? {
this.getPrimaryConstructorParameterList()?.parameters?.forEach { param ->
if (!param.annotationEntries.any {
it.shortName?.asString() == "SerializedName"
}
) {
return param
}
}
return null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment