reactormonk
07/14/2022, 8:09 AMTLV<T>
signature, and just use TLV
to represent it, if I'm using the interface to designate the type?
sealed interface TLV<T> {
val value: T
val type: Byte
}
object TLVNULL: TLV<Unit> {
override val type: Byte = 0x00
override val value: Unit = Unit
}
data class TLVNDEF(override val value: NdefMessage): TLV<NdefMessage> {
override val type: Byte = 0x03
}
data class TLVProp(override val value: ByteArray): TLV<ByteArray> {
override val type: Byte = 0xFD.toByte()
}
object TLVTerminator: TLV<Unit> {
override val type: Byte = 0xFE.toByte()
override val value: Unit = Unit
}
Youssef Shoaib [MOD]
07/14/2022, 8:27 AM<T>
and the val value: T
inside the interface. Then, you'll only have access to the value if you know which subclass of TLV
you have. I think that leaving it as-is could be a better design though.