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

uidsonic.fluid-json-coding.0.9.10.source-code.JSONCodecProvider.kt Maven / Gradle / Ivy

There is a newer version: 0.9.24
Show newest version
package com.github.fluidsonic.fluid.json

import kotlin.reflect.KClass


interface JSONCodecProvider {

	fun  decoderCodecForType(decodableType: JSONCodingType): JSONDecoderCodec?
	fun  encoderCodecForClass(encodableClass: KClass): JSONEncoderCodec?


	companion object {

		val basic = of(DefaultJSONCodecs.basic + DefaultJSONCodecs.nonRecursive)
		val extended = of(DefaultJSONCodecs.extended + DefaultJSONCodecs.basic + DefaultJSONCodecs.nonRecursive)


		fun  of(
			vararg providers: JSONCodecProvider,
			base: JSONCodecProvider? = extended
		) =
			of(providers.asIterable(), base = base)


		fun  of(
			providers: Iterable>,
			base: JSONCodecProvider? = extended
		): JSONCodecProvider =
			StandardCodecProvider(providers = base?.let { providers + it } ?: providers)
	}
}


inline fun  JSONCodecProvider.decoderCodecForType() =
	decoderCodecForType(jsonCodingType())


inline fun  JSONCodecProvider.encoderCodecForClass() =
	encoderCodecForClass(Value::class)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy