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

de.lancom.openapi.entity.XML.kt Maven / Gradle / Ivy

Go to download

This open-source project provides an OpenAPI 3.0 Parser implemented in Kotlin, utilizing immutable data classes

There is a newer version: 2.1.1
Show newest version
/*****************************************************************************
**   C A U T I O N                                                          **
**   This file is auto-generated!                                           **
**   If you want to make changes, please see the README.md file.            **
**   Please do not edit this file directly!                                 **
*****************************************************************************/
package de.lancom.openapi.entity

import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import de.lancom.openapi.field.Field
import de.lancom.openapi.jackson.EntityDeserializer
import de.lancom.openapi.jackson.EntitySerializer
import de.lancom.openapi.jackson.Parser
import de.lancom.openapi.jackson.Wrapper
import de.lancom.openapi.tools.toYamlString

// hint:9A1BF04C
@Suppress("PropertyName")
@JsonSerialize(using = XML.Companion.Serializer::class)
@JsonDeserialize(using = XML.Companion.Deserializer::class)
data class XML(
    val _jsonNode: Field = Field.unset(),
) : Entity {

    ///////////////////////
    //
    // jsonNode
    //
    ///////////////////////

    // hint:3A7F9B2E
    val jsonNode: JsonNode
        get() = _jsonNode.getOrError()

    // hint:F0C48D71
    fun setJsonNodeField(jsonNode: Field): XML {
        return copy(_jsonNode = jsonNode)
    }

    // hint:8E56A4D9
    fun updateJsonNodeField(updater: (Field) -> Field): XML {
        return setJsonNodeField(updater(_jsonNode))
    }

    // hint:B1D730FC
    fun updateJsonNode(updater: (JsonNode) -> JsonNode): XML {
        return updateJsonNodeField { field ->
            field.flatMap { value ->
                Field(updater(value))
            }
        }
    }

    // hint:6542E98A
    fun mergeJsonNodeField(jsonNodeFieldToMerge: Field): XML {
        return mergeJsonNode(jsonNodeFieldToMerge.orNull)
    }

    // hint:A8BC6F23
    fun mergeJsonNode(jsonNodeToMerge: JsonNode?): XML {
        return if (jsonNodeToMerge == null) {
            this
        } else {
            val oldJsonNode = _jsonNode.orNull
            if (oldJsonNode == null) {
                setJsonNodeField(Field(jsonNodeToMerge))
            } else {
                // hint:2F684DAC
                setJsonNode(jsonNodeToMerge)
            }
        }
    }

    // hint:87B3E19C
    fun setJsonNode(jsonNode: JsonNode): XML {
        return setJsonNodeField(Field(jsonNode))
    }

    // hint:D465F782
    fun unsetJsonNode(): XML {
        return setJsonNodeField(Field.unset())
    }

    // hint:47C9A0F6
    fun addJsonNode(jsonNode: JsonNode): XML {
        return setJsonNode(jsonNode)
    }

    // hint:6A81E3FD
    override val entityDescriptor: EntityDescriptor by lazy {
        EntityDescriptor(
            entity = this,
            jsonNode = _jsonNode,
            map = mapOf(
            ),
            flatMap = listOf(
            ),
            flatten = listOf(
            ),
        )
    }

    override fun toString(): String {
        return this.toYamlString()
    }

    // hint:A0E5F382
    override fun mergeEntity(other: Entity?): XML {
        return when (other) {
            null ->
                this

            is XML ->
                merge(other)

            else ->
                TODO()
        }
    }

    // hint:716BFD54
    fun merge(other: XML?): XML {
        if (other == null) return this
        return this
            .mergeJsonNodeField(other._jsonNode)
    }

    companion object : JsonEntityFactory {

        class Serializer : EntitySerializer(XML::class.java, XML)
        class Deserializer : EntityDeserializer(XML::class.java, XML)

        // hint:5F72B6D8
        override fun parseWrapper(wrapper: Wrapper): XML {
            return XML(
                _jsonNode = wrapper.jsonNodeFieldOrUnsetIfEmpty,
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy