anatawa12 / auto-tostring

A kotlin compiler plugin to generate toString like data class.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto ToString Kotlin Compiler Plugin

a12 maintenance: Slowly

A kotlin compiler plugin to generate toString like data class.

How to use

First, you need to apply this gradle plugin

plugins {
 id("org.jetbrains.kotlin.jvm") version "<kotlin version>"
 id("com.anatawa12.auto-tostring") version "<version>"
}

To add compile-time library, add code below:

autoToString {
 // for compileOnly configuration
 addLib()
 // for <source-set>CompileOnly configuration
 addLib "sourceSet"
 addLib sourceSet: "sourceSet"
 // for your configuration
 addLib configuration: "yourConfiguration"
}

To generate toString function, add @AutoToString annotation to class.

Extra features

For kotlin.String or string it typed fields, This plugin surrounded the value with " like SomeClass(value="string body") and also surrounded with ' for kotlin.Chars.

You can customize wrapping with @SurroundedWith(begin=, end=). see KDoc for more details.

About

A kotlin compiler plugin to generate toString like data class.

License:MIT License


Languages

Language:Kotlin 100.0%