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

kz.btsd.messenger.bot.domain.InterfaceView.kt Maven / Gradle / Ivy

The newest version!
package kz.btsd.messenger.bot.domain

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kz.btsd.messenger.bot.domain.content.Content

data class InterfaceView(
        val type: String,
        val id: String? = null,
        var content: MutableList
) {
    companion object {
        private val JSON = jacksonObjectMapper()

        init {
            JSON.setSerializationInclusion(JsonInclude.Include.NON_NULL)
        }

        fun of(json: String): InterfaceView {
            return JSON.readValue(json, InterfaceView::class.java)
        }

        fun validation(json: String): String {
            val interfaceView = InterfaceView.of(json)
            return interfaceView.toJson()
        }

    }

    fun toJson(): String {
        return InterfaceView.JSON.writeValueAsString(this)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy