Anyone knows if there is a way (e.g., a plugin) to...
# random
e
Anyone knows if there is a way (e.g., a plugin) to generate a
copy
function without
hashCode
and
toString
? I don't want to use data classes in certain environments.
h
There is poko but it also generates hashCode and toString https://github.com/drewhamilton/Poko
You could fork it and remove the hashCode/toString implementation though.
e
Ah wait, but Poko does the opposite, it generates everything but not
copy
.
h
Oh, yeah 🤦🏻‍♂️
d
You could do
Copy code
abstract class CopyOnly {
  final override fun equals(other: Any?): Boolean = super.equals(other)
  final override fun hashCode(): Int = super.hashCode()
  final override fun toString(): String = super.toString()
}

data class MyData(
  val asdf: Int,
) : CopyOnly()
That would also leave you with the
componentN
functions though
a
e
@Adam S works only on data classes unfortunately.
Same for the maintained Kopy alternative.