All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
de.lancom.openapi.entity.Response.kt Maven / Gradle / Ivy
Go to download
This open-source project provides an OpenAPI 3.0 Parser implemented in Kotlin, utilizing immutable data classes
/*****************************************************************************
** 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.Instance
import de.lancom.openapi.refs.ReferenceOrInstance
import de.lancom.openapi.refs.Referenceable
import de.lancom.openapi.tools.toYamlString
// hint:9A1BF04C
@Suppress("PropertyName")
@JsonSerialize(using = Response.Companion.Serializer::class)
@JsonDeserialize(using = Response.Companion.Deserializer::class)
data class Response(
val _description: Field = Field.unset(),
val _headers: Field?> = Field.unset(),
val _content: Field?> = Field.unset(),
val _links: Field?>?> = Field.unset(),
val _extensions: Field> = Field.unset(),
) : Referenceable {
///////////////////////
//
// description
//
///////////////////////
// hint:3A7F9B2E
val description: String?
get() = _description.orNull
// hint:F0C48D71
fun setDescriptionField(description: Field): Response {
return copy(_description = description)
}
// hint:8E56A4D9
fun updateDescriptionField(updater: (Field) -> Field): Response {
return setDescriptionField(updater(_description))
}
// hint:B1D730FC
fun updateDescription(updater: (String?) -> String?): Response {
return updateDescriptionField { field ->
field.flatMap { value ->
Field(updater(value))
}
}
}
// hint:6542E98A
fun mergeDescriptionField(descriptionFieldToMerge: Field): Response {
return mergeDescription(descriptionFieldToMerge.orNull)
}
// hint:A8BC6F23
fun mergeDescription(descriptionToMerge: String?): Response {
return if (descriptionToMerge == null) {
this
} else {
val oldDescription = _description.orNull
if (oldDescription == null) {
setDescriptionField(Field(descriptionToMerge))
} else {
// hint:2F684DAC
setDescription(descriptionToMerge)
}
}
}
// hint:87B3E19C
fun setDescription(description: String?): Response {
return setDescriptionField(Field(description))
}
// hint:D465F782
fun unsetDescription(): Response {
return setDescriptionField(Field.unset())
}
// hint:47C9A0F6
fun addDescription(description: String): Response {
if (this.description != null) {
throw IllegalStateException("Field description of Entity Response is already set to '${this.description}', refused to add new value '$description'")
}
return setDescription(description)
}
///////////////////////
//
// headers
//
///////////////////////
// hint:3A7F9B2E
val headers: Map?
get() = _headers.orNull
// hint:F0C48D71
fun setHeadersField(headers: Field?>): Response {
return copy(_headers = headers)
}
// hint:8E56A4D9
fun updateHeadersField(updater: (Field?>) -> Field?>): Response {
return setHeadersField(updater(_headers))
}
// hint:B1D730FC
fun updateHeaders(updater: (Map?) -> Map?): Response {
return updateHeadersField { field ->
field.flatMap { value ->
Field(updater(value))
}
}
}
// hint:6542E98A
fun mergeHeadersField(headersFieldToMerge: Field?>): Response {
return mergeHeaders(headersFieldToMerge.orNull)
}
// hint:A8BC6F23
fun mergeHeaders(headersToMerge: Map?): Response {
return if (headersToMerge == null) {
this
} else {
val oldHeaders = _headers.orNull
if (oldHeaders == null) {
setHeadersField(Field(headersToMerge))
} else {
// hint:70A3D8B6
setHeaders(de.lancom.openapi.tools.mergeMap(oldHeaders, headersToMerge))
}
}
}
// hint:87B3E19C
fun setHeaders(headers: Map?): Response {
return setHeadersField(Field(headers))
}
// hint:D465F782
fun unsetHeaders(): Response {
return setHeadersField(Field.unset())
}
// hint:5C81D396
fun addHeaders(headers: Map?): Response {
return mergeHeaders(headers)
}
// hint:1A6B37F8
fun addHeaders(vararg headers: Pair): Response {
return addHeaders(headers.toMap())
}
// hint:9D0E4CA5
fun addHeader(key: String, value: Header?): Response {
return addHeaders(key to value)
}
// hint:B8F25E73
fun addHeader(pair: Pair): Response {
return addHeaders(mapOf(pair))
}
///////////////////////
//
// content
//
///////////////////////
// hint:3A7F9B2E
val content: Map?
get() = _content.orNull
// hint:F0C48D71
fun setContentField(content: Field?>): Response {
return copy(_content = content)
}
// hint:8E56A4D9
fun updateContentField(updater: (Field?>) -> Field?>): Response {
return setContentField(updater(_content))
}
// hint:B1D730FC
fun updateContent(updater: (Map?) -> Map?): Response {
return updateContentField { field ->
field.flatMap { value ->
Field(updater(value))
}
}
}
// hint:6542E98A
fun mergeContentField(contentFieldToMerge: Field?>): Response {
return mergeContent(contentFieldToMerge.orNull)
}
// hint:A8BC6F23
fun mergeContent(contentToMerge: Map?): Response {
return if (contentToMerge == null) {
this
} else {
val oldContent = _content.orNull
if (oldContent == null) {
setContentField(Field(contentToMerge))
} else {
// hint:70A3D8B6
setContent(de.lancom.openapi.tools.mergeMap(oldContent, contentToMerge))
}
}
}
// hint:87B3E19C
fun setContent(content: Map?): Response {
return setContentField(Field(content))
}
// hint:D465F782
fun unsetContent(): Response {
return setContentField(Field.unset())
}
// hint:5C81D396
fun addContent(content: Map?): Response {
return mergeContent(content)
}
// hint:1A6B37F8
fun addContent(vararg content: Pair): Response {
return addContent(content.toMap())
}
// hint:9D0E4CA5
fun addContent(key: String, value: MediaType?): Response {
return addContent(key to value)
}
// hint:B8F25E73
fun addContent(pair: Pair): Response {
return addContent(mapOf(pair))
}
///////////////////////
//
// links
//
///////////////////////
// hint:3A7F9B2E
val links: Map?>?
get() = _links.orNull
// hint:F0C48D71
fun setLinksField(links: Field?>?>): Response {
return copy(_links = links)
}
// hint:8E56A4D9
fun updateLinksField(updater: (Field?>?>) -> Field?>?>): Response {
return setLinksField(updater(_links))
}
// hint:B1D730FC
fun updateLinks(updater: (Map?>?) -> Map?>?): Response {
return updateLinksField { field ->
field.flatMap { value ->
Field(updater(value))
}
}
}
// hint:6542E98A
fun mergeLinksField(linksFieldToMerge: Field?>?>): Response {
return mergeLinks(linksFieldToMerge.orNull)
}
// hint:A8BC6F23
fun mergeLinks(linksToMerge: Map?>?): Response {
return if (linksToMerge == null) {
this
} else {
val oldLinks = _links.orNull
if (oldLinks == null) {
setLinksField(Field(linksToMerge))
} else {
// hint:70A3D8B6
setLinks(de.lancom.openapi.tools.mergeMap(oldLinks, linksToMerge))
}
}
}
// hint:87B3E19C
fun setLinks(links: Map?>?): Response {
return setLinksField(Field(links))
}
// hint:D465F782
fun unsetLinks(): Response {
return setLinksField(Field.unset())
}
// hint:5C81D396
fun addLinks(links: Map?>?): Response {
return mergeLinks(links)
}
// hint:1A6B37F8
fun addLinks(vararg links: Pair?>): Response {
return addLinks(links.toMap())
}
// hint:9D0E4CA5
fun addLink(key: String, value: ReferenceOrInstance ?): Response {
return addLinks(key to value)
}
// hint:B8F25E73
fun addLink(pair: Pair?>): Response {
return addLinks(mapOf(pair))
}
// hint: 4F7A83E9
fun addLink(key: String, value: Link): Response {
return addLinks(key to Instance(value))
}
///////////////////////
//
// extensions
//
///////////////////////
// hint:3A7F9B2E
val extensions: Map
get() = _extensions.orNull ?: emptyMap()
// hint:F0C48D71
fun setExtensionsField(extensions: Field>): Response {
return copy(_extensions = extensions)
}
// hint:8E56A4D9
fun updateExtensionsField(updater: (Field>) -> Field>): Response {
return setExtensionsField(updater(_extensions))
}
// hint:B1D730FC
fun updateExtensions(updater: (Map) -> Map): Response {
return updateExtensionsField { field ->
field.flatMap { value ->
Field(updater(value))
}
}
}
// hint:6542E98A
fun mergeExtensionsField(extensionsFieldToMerge: Field>): Response {
return mergeExtensions(extensionsFieldToMerge.orNull)
}
// hint:A8BC6F23
fun mergeExtensions(extensionsToMerge: Map?): Response {
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): Response {
return setExtensionsField(Field(extensions))
}
// hint:D465F782
fun unsetExtensions(): Response {
return setExtensionsField(Field.unset())
}
// hint:5C81D396
fun addExtensions(extensions: Map): Response {
return mergeExtensions(extensions)
}
// hint:1A6B37F8
fun addExtensions(vararg extensions: Pair): Response {
return addExtensions(extensions.toMap())
}
// hint:9D0E4CA5
fun addExtension(key: String, value: Extension?): Response {
return addExtensions(key to value)
}
// hint:B8F25E73
fun addExtension(pair: Pair): Response {
return addExtensions(mapOf(pair))
}
// hint:6A81E3FD
override val entityDescriptor: EntityDescriptor by lazy {
EntityDescriptor(
entity = this,
jsonNode = null,
map = mapOf(
"description" to _description,
"headers" to _headers,
"content" to _content,
"links" to _links,
),
flatMap = listOf(
_extensions,
),
flatten = listOf(
),
)
}
override fun toString(): String {
return this.toYamlString()
}
// hint:A0E5F382
override fun mergeEntity(other: Entity?): Response {
return when (other) {
null ->
this
is Response ->
merge(other)
else ->
TODO()
}
}
// hint:716BFD54
fun merge(other: Response?): Response {
if (other == null) return this
return this
.mergeDescriptionField(other._description)
.mergeHeadersField(other._headers)
.mergeContentField(other._content)
.mergeLinksField(other._links)
.mergeExtensionsField(other._extensions)
}
companion object : ReferenceParser {
class Serializer : EntitySerializer(Response::class.java, Response)
class Deserializer : EntityDeserializer(Response::class.java, Response)
// hint:5F72B6D8
override fun parseWrapper(wrapper: Wrapper): Response {
return de.lancom.openapi.jackson.extensionParser(wrapper, ::parseWrapperWithExtensions)
}
// hint:2C0E94A7
fun parseWrapperWithExtensions(wrapper: Wrapper, extensions: Field>): Response {
return Response(
_description = wrapper["description"].getNullOrElse {
getSingle {
getSingle {
getString()
}
}
},
_headers = wrapper["headers"].getNullOrElse {
getMap {
getNullOrElse {
getSingle(Header::parseEntityOpt)
}
}
},
_content = wrapper["content"].getNullOrElse {
getMap {
getNullOrElse {
getSingle(MediaType::parseEntityOpt)
}
}
},
_links = wrapper["links"].getNullOrElse {
getMap {
getNullOrElse {
getSingle(Link::parseReferenceOrEntityOpt)
}
}
},
_extensions = extensions,
)
}
}
}