{{^multiplatform}}
{{#gson}}
import com.google.gson.annotations.SerializedName
{{/gson}}
{{#moshi}}
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
{{/moshi}}
{{#jackson}}
import com.fasterxml.jackson.annotation.JsonProperty
{{#discriminator}}
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
{{/discriminator}}
{{/jackson}}
{{#kotlinx_serialization}}
import {{#serializableModel}}kotlinx.serialization.Serializable as KSerializable{{/serializableModel}}{{^serializableModel}}kotlinx.serialization.Serializable{{/serializableModel}}
import kotlinx.serialization.SerialName
import kotlinx.serialization.Contextual
{{#enumUnknownDefaultCase}}
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializer
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
{{/enumUnknownDefaultCase}}
{{#hasEnums}}
{{/hasEnums}}
{{/kotlinx_serialization}}
{{#parcelizeModels}}
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
{{/parcelizeModels}}
{{/multiplatform}}
{{#multiplatform}}
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
{{/multiplatform}}
{{#serializableModel}}
import java.io.Serializable
{{/serializableModel}}
{{#generateRoomModels}}
import {{roomModelPackage}}.{{classname}}RoomModel
import {{packageName}}.infrastructure.ITransformForStorage
{{/generateRoomModels}}
import java.util.Objects

/**
 * {{{description}}}
 *
{{#allVars}}
 * @param {{{name}}} {{{description}}}
{{/allVars}}
 */
{{#parcelizeModels}}
@Parcelize
{{/parcelizeModels}}
{{#multiplatform}}{{^discriminator}}@Serializable{{/discriminator}}{{/multiplatform}}{{#kotlinx_serialization}}{{#serializableModel}}@KSerializable{{/serializableModel}}{{^serializableModel}}@Serializable{{/serializableModel}}{{/kotlinx_serialization}}{{#moshi}}{{#moshiCodeGen}}@JsonClass(generateAdapter = true){{/moshiCodeGen}}{{/moshi}}{{#jackson}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{/jackson}}
{{#isDeprecated}}
@Deprecated(message = "This schema is deprecated.")
{{/isDeprecated}}
{{>additionalModelTypeAnnotations}}
{{#nonPublicApi}}internal {{/nonPublicApi}}{{#discriminator}}interface{{/discriminator}}{{^discriminator}}{{^nonPublicApi}}public {{/nonPublicApi}}class{{/discriminator}} {{classname}}{{^discriminator}} internal constructor(

{{#allVars}}
{{#required}}{{>data_class_req_var}}{{/required}}{{^required}}{{>data_class_opt_var}}{{/required}}{{^-last}},{{/-last}}

{{/allVars}}
){{/discriminator}}{{#parent}}{{^serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{^serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{^parcelizeModels}} : Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{^serializableModel}}{{#parcelizeModels}} : Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{#parcelizeModels}} : Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#generateRoomModels}}{{#parent}}, {{/parent}}{{^discriminator}}{{^parent}}:{{/parent}} ITransformForStorage<{{classname}}RoomModel>{{/discriminator}}{{/generateRoomModels}} {

{{#generateRoomModels}}
    companion object { }
    {{^discriminator}}override fun toRoomModel(): {{classname}}RoomModel =
        {{classname}}RoomModel(roomTableId = 0,
        {{#allVars}}{{#items.isPrimitiveType}}{{#isArray}}{{#isList}}{{name}} = this.{{name}},{{/isList}}{{/isArray}}{{/items.isPrimitiveType}}{{^isEnum}}{{^isArray}}{{name}} = this.{{name}},{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{name}} = this.{{name}},{{/isArray}}{{/isEnum}}
        {{/allVars}}
        ){{/discriminator}}
{{/generateRoomModels}}
{{#serializableModel}}
    {{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
        private const val serialVersionUID: Long = 123
    }
{{/serializableModel}}
{{#discriminator}}{{#vars}}{{#required}}
{{>interface_req_var}}{{/required}}{{^required}}
{{>interface_opt_var}}{{/required}}{{/vars}}{{/discriminator}}
{{#hasEnums}}
{{#vars}}
{{#isEnum}}
    /**
     * {{{description}}}
     *
     * Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
     */
    {{^multiplatform}}
    {{#kotlinx_serialization}}
    {{#serializableModel}}@KSerializable{{/serializableModel}}{{^serializableModel}}@Serializable{{#enumUnknownDefaultCase}}(with = {{classname}}Serializer::class){{/enumUnknownDefaultCase}}{{/serializableModel}}
    {{/kotlinx_serialization}}
    {{#moshi}}
    @JsonClass(generateAdapter = false)
    {{/moshi}}
    {{/multiplatform}}
    {{#multiplatform}}
    @Serializable
    {{/multiplatform}}
    {{#nonPublicApi}}internal {{/nonPublicApi}}{{^nonPublicApi}}public {{/nonPublicApi}}enum class {{{nameInCamelCase}}}({{^nonPublicApi}}public {{/nonPublicApi}}val value: {{^isContainer}}{{dataType}}{{/isContainer}}{{#isContainer}}kotlin.String{{/isContainer}}) {
    {{#allowableValues}}
    {{#enumVars}}
        {{^multiplatform}}
        {{#moshi}}
        @Json(name = {{#lambda.doublequote}}{{{value}}}{{/lambda.doublequote}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
        {{/moshi}}
        {{#gson}}
        @SerializedName(value = {{#lambda.doublequote}}{{{value}}}{{/lambda.doublequote}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
        {{/gson}}
        {{#jackson}}
        @JsonProperty(value = {{#lambda.doublequote}}{{{value}}}{{/lambda.doublequote}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
        {{/jackson}}
        {{#kotlinx_serialization}}
        @SerialName(value = {{#lambda.doublequote}}{{{value}}}{{/lambda.doublequote}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
        {{/kotlinx_serialization}}
        {{/multiplatform}}
        {{#multiplatform}}
        @SerialName(value = {{#lambda.doublequote}}{{{value}}}{{/lambda.doublequote}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
        {{/multiplatform}}
    {{/enumVars}}
    {{/allowableValues}}
    }{{#kotlinx_serialization}}{{#enumUnknownDefaultCase}}

    @Serializer(forClass = {{{nameInCamelCase}}}::class)
    internal object {{nameInCamelCase}}Serializer : KSerializer<{{nameInCamelCase}}> {
        override val descriptor = {{{dataType}}}.serializer().descriptor

        override fun deserialize(decoder: Decoder): {{nameInCamelCase}} {
            val value = decoder.decodeSerializableValue({{{dataType}}}.serializer())
            return {{nameInCamelCase}}.values().firstOrNull { it.value == value }
                ?: {{nameInCamelCase}}.{{#allowableValues}}{{#enumVars}}{{#-last}}{{&name}}{{/-last}}{{/enumVars}}{{/allowableValues}}
        }

        override fun serialize(encoder: Encoder, value: {{nameInCamelCase}}) {
            encoder.encodeSerializableValue({{{dataType}}}.serializer(), value.value)
        }
    }{{/enumUnknownDefaultCase}}{{/kotlinx_serialization}}
{{/isEnum}}
{{/vars}}
{{/hasEnums}}

{{^isEnum}}
	override fun toString() : String = "{{classname}}({{#allVars}}{{className}}{{name}}=${{name}}{{^-last}}, {{/-last}}{{/allVars}})"
	override fun equals(other: Any?) : Boolean = other is {{classname}}
		{{#allVars}}&& {{name}} == other.{{name}}
		{{/allVars}}
    override fun hashCode(): Int = Objects.hash({{#allVars}}{{name}}{{^-last}},{{/-last}}{{/allVars}})

	public class Builder {
		{{#allVars}}
			{{#description}}
				/* {{{.}}} */
			{{/description}}
			@set:JvmSynthetic // Hide 'void' setter from Java
			public var {{name}}: {{#isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = null
		{{/allVars}}

		{{#allVars}}
			public fun set{{nameInCamelCase}}({{name}}: {{#isEnum}}{{classname}}.{{{nameInCamelCase}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}?): Builder = apply { this.{{name}} = {{name}} }
		{{/allVars}}
		public fun build(): {{classname}} = {{classname}}({{#allVars}}{{name}}{{#required}}!!{{/required}}{{^-last}},{{/-last}}{{/allVars}})
	}
{{/isEnum}}
}

{{^isEnum}}
@JvmSynthetic // Hide from Java callers who should use Builder.
public fun {{classname}}(initializer: {{classname}}.Builder.() -> Unit): {{classname}} {
  return {{classname}}.Builder().apply(initializer).build()
}
{{/isEnum}}
