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

commands.BakuCommandFactory.kt Maven / Gradle / Ivy

There is a newer version: 0.9.27
Show newest version
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