Jonathan Mew
08/27/2021, 2:48 PMvalue class
queries 🧵MyCaseInsensitiveString.new(s)
and pass the lowercased string to a private constructor to preserve that logic.
• We have Exposed Column Types related to our Microtypes - so we have an abstract class StringMicrotypeColumnType<T: StringMicrotype>
extended by a few others, each associated with the relevant Microtype (e.g. EmailColumnType
associated with Email
). Is there a way to use generics to refer to "any value class that contains a String value"?@JvmInline
value class EmailAddress private constructor(val value: String) {
companion object {
fun new(value: String): EmailAddress = EmailAddress(value.lowercase())
}
}
Stephan Schroeder
08/30/2021, 6:57 AMinterface StringContainer {
fun getContent(): String
}
Jonathan Mew
08/31/2021, 7:46 AMinterface StringContainer {
val value: String
}
@JvmInline
value class EmailAddress private constructor(override val value: String): StringContainer {
...
}
Not sure it's worth it though 🤔
Thanks for the input!