In Kotlin, it's possible to generate toString()
method for data classes:
data class Foo(...)
But there are some limitations on using data classes, plus Kotlin compiler generates additional methods, which I don't want to have in my code.
In Java, you can generate toString()
method with Lombok just by adding one line of code with @ToString
annotation:
@ToString
public class Foo {
...
}
Unfortunately, Lombok doesn't work with Kotlin, so I have to implement toString()
method manually each time:
class Foo {
...
override fun toString(): String {
// bunch of code here
}
}
Is there any shorthand syntax for this in Kotlin or maybe some third-party solution?