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

de.lancom.openapi.entity.Callback.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.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.ReferenceParser
import de.lancom.openapi.jackson.Wrapper
import de.lancom.openapi.refs.Referenceable
import de.lancom.openapi.tools.toYamlString

// hint:9A1BF04C
@Suppress("PropertyName")
@JsonSerialize(using = Callback.Companion.Serializer::class)
@JsonDeserialize(using = Callback.Companion.Deserializer::class)
data class Callback(
    val _pathItems: Field> = Field.unset(),
    val _extensions: Field> = Field.unset(),
) : Referenceable {

    ///////////////////////
    //
    // pathItems
    //
    ///////////////////////

    // hint:3A7F9B2E
    val pathItems: Map
        get() = _pathItems.orNull ?: emptyMap()

    // hint:F0C48D71
    fun setPathItemsField(pathItems: Field>): Callback {
        return copy(_pathItems = pathItems)
    }

    // hint:8E56A4D9
    fun updatePathItemsField(updater: (Field>) -> Field>): Callback {
        return setPathItemsField(updater(_pathItems))
    }

    // hint:B1D730FC
    fun updatePathItems(updater: (Map) -> Map): Callback {
        return updatePathItemsField { field ->
            field.flatMap { value ->
                Field(updater(value))
            }
        }
    }

    // hint:6542E98A
    fun mergePathItemsField(pathItemsFieldToMerge: Field>): Callback {
        return mergePathItems(pathItemsFieldToMerge.orNull)
    }

    // hint:A8BC6F23
    fun mergePathItems(pathItemsToMerge: Map?): Callback {
        return if (pathItemsToMerge == null) {
            this
        } else {
            val oldPathItems = _pathItems.orNull
            if (oldPathItems == null) {
                setPathItemsField(Field(pathItemsToMerge))
            } else {
                // hint:70A3D8B6
                setPathItems(de.lancom.openapi.tools.mergeMap(oldPathItems, pathItemsToMerge))
            }
        }
    }

    // hint:87B3E19C
    fun setPathItems(pathItems: Map): Callback {
        return setPathItemsField(Field(pathItems))
    }

    // hint:D465F782
    fun unsetPathItems(): Callback {
        return setPathItemsField(Field.unset())
    }

    // hint:5C81D396
    fun addPathItems(pathItems: Map): Callback {
        return mergePathItems(pathItems)
    }

    // hint:1A6B37F8
    fun addPathItems(vararg pathItems: Pair): Callback {
        return addPathItems(pathItems.toMap())
    }

    // hint:9D0E4CA5
    fun addPathItem(key: String, value: PathItem?): Callback {
        return addPathItems(key to value)
    }

    // hint:B8F25E73
    fun addPathItem(pair: Pair): Callback {
        return addPathItems(mapOf(pair))
    }

    ///////////////////////
    //
    // extensions
    //
    ///////////////////////

    // hint:3A7F9B2E
    val extensions: Map
        get() = _extensions.orNull ?: emptyMap()

    // hint:F0C48D71
    fun setExtensionsField(extensions: Field>): Callback {
        return copy(_extensions = extensions)
    }

    // hint:8E56A4D9
    fun updateExtensionsField(updater: (Field>) -> Field>): Callback {
        return setExtensionsField(updater(_extensions))
    }

    // hint:B1D730FC
    fun updateExtensions(updater: (Map) -> Map): Callback {
        return updateExtensionsField { field ->
            field.flatMap { value ->
                Field(updater(value))
            }
        }
    }

    // hint:6542E98A
    fun mergeExtensionsField(extensionsFieldToMerge: Field>): Callback {
        return mergeExtensions(extensionsFieldToMerge.orNull)
    }

    // hint:A8BC6F23
    fun mergeExtensions(extensionsToMerge: Map?): Callback {
        return if (extensionsToMerge == null) {
            this
        } else {
            val oldExtensions = _extensions.orNull
            if (oldExtensions == null) {
                setExtensionsField(Field(extensionsToMerge))
            } else {
                // hint:70A3D8B6
                setExtensions(de.lancom.openapi.tools.mergeMap(oldExtensions, extensionsToMerge))
            }
        }
    }

    // hint:87B3E19C
    fun setExtensions(extensions: Map): Callback {
        return setExtensionsField(Field(extensions))
    }

    // hint:D465F782
    fun unsetExtensions(): Callback {
        return setExtensionsField(Field.unset())
    }

    // hint:5C81D396
    fun addExtensions(extensions: Map): Callback {
        return mergeExtensions(extensions)
    }

    // hint:1A6B37F8
    fun addExtensions(vararg extensions: Pair): Callback {
        return addExtensions(extensions.toMap())
    }

    // hint:9D0E4CA5
    fun addExtension(key: String, value: Extension?): Callback {
        return addExtensions(key to value)
    }

    // hint:B8F25E73
    fun addExtension(pair: Pair): Callback {
        return addExtensions(mapOf(pair))
    }

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

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

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

            is Callback ->
                merge(other)

            else ->
                TODO()
        }
    }

    // hint:716BFD54
    fun merge(other: Callback?): Callback {
        if (other == null) return this
        return this
            .mergePathItemsField(other._pathItems)
            .mergeExtensionsField(other._extensions)
    }

    companion object : ReferenceParser {

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

        // hint:5F72B6D8
        override fun parseWrapper(wrapper: Wrapper): Callback {
            return de.lancom.openapi.jackson.extensionParser(wrapper, ::parseWrapperWithExtensions)
        }

        // hint:2C0E94A7
        fun parseWrapperWithExtensions(wrapper: Wrapper, extensions: Field>): Callback {
            return Callback(
                _pathItems = wrapper.getUnlessEmpty {
                    getMap {
                        getNullOrElse {
                            getSingle(PathItem::parseEntityOpt)
                        }
                    }
                },
                _extensions = extensions,
            )
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy