All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commands.BakuCommandFactory.kt Maven / Gradle / Ivy

package com.github.fluidsonic.baku

import com.github.fluidsonic.fluid.json.*


abstract class BakuCommandFactory(
	name: String
) {

	val name = BakuCommandName(name)


	abstract fun JSONDecoder.decodeCommand(): Command


	open fun JSONEncoder.encodeResult(result: Result) {
		writeIntoMap {}
	}


	abstract class Empty(
		name: String
	) : BakuCommandFactory(name = name) {

		abstract fun createCommand(): Command


		final override fun JSONDecoder.decodeCommand() =
			createCommand().also { skipValue() }
	}
}


fun  BakuCommandFactory.encodeResult(result: Result, encoder: JSONEncoder) =
	encoder.encodeResult(result)





© 2015 - 2024 Weber Informatics LLC | Privacy Policy