fun deprecatedAnnotation()

in graphql-dgs-codegen-core/src/main/kotlin/com/netflix/graphql/dgs/codegen/generators/kotlin/KotlinPoetUtils.kt [222:242]


fun deprecatedAnnotation(reason: String): AnnotationSpec {
    // TODO support for level
    val replace = reason.substringAfter(ParserConstants.REPLACE_WITH_STR, "")
    val builder: AnnotationSpec.Builder =
        AnnotationSpec
            .builder(Deprecated::class)
            .addMember(
                "${ParserConstants.MESSAGE}${ParserConstants.ASSIGNMENT_OPERATOR}%S",
                reason.substringBefore(ParserConstants.REPLACE_WITH_STR),
            )
    if (replace.isNotEmpty()) {
        builder.addMember(
            CodeBlock.of(
                "${ParserConstants.REPLACE_WITH}${ParserConstants.ASSIGNMENT_OPERATOR}%M(%S)",
                MemberName("kotlin", ParserConstants.REPLACE_WITH_CLASS),
                reason.substringAfter(ParserConstants.REPLACE_WITH_STR),
            ),
        )
    }
    return builder.build()
}