I have the following code, and I need a lot of sim...
# announcements
k
I have the following code, and I need a lot of similar looking ones. What is the easiest way to generate these?
Copy code
class Handshake (val ProtocolVersion : Int,
				 val ServerAdress : String,
				 val port : UShort,
				 val NextState : Int): Packet{



	override suspend fun sendData(channel: WriteByteChannel) {
		channel.write {
			varInt(ProtocolVersion)
			string(ServerAdress)
			uShort(port)
			varInt(NextState)
		}
	}

	


	companion object {
		fun parse(channel: ReadByteChannel) = Handshake(
			ProtocolVersion = channel.readVarInt(),
			ServerAdress = channel.readString(255),
			port = channel.readUShort(),
			NextState = channel.readVarInt()
		)
	}
}
d
Using kotlinpoet in
buildSrc
to generate the kotlin code at compile time.
Depending on the similarity you could use
kotlinx.serialization
to do the generation for you.