de.lancom.openapi.entity.AdditionalPropertiesSchema.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-parser Show documentation
Show all versions of openapi-parser Show documentation
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.refs.Instance
import de.lancom.openapi.tools.toYamlString
// hint:9A1BF04C
@Suppress("PropertyName")
@JsonSerialize(using = AdditionalProperties.Companion.Serializer::class)
@JsonDeserialize(using = AdditionalProperties.Companion.Deserializer::class)
data class AdditionalPropertiesSchema(
val _schema: Field = Field.unset(),
) : AdditionalProperties {
///////////////////////
//
// schema
//
///////////////////////
// hint:3A7F9B2E
val schema: Schema?
get() = _schema.orNull
// hint:F0C48D71
fun setSchemaField(schema: Field): AdditionalPropertiesSchema {
return copy(_schema = schema)
}
// hint:8E56A4D9
fun updateSchemaField(updater: (Field) -> Field): AdditionalPropertiesSchema {
return setSchemaField(updater(_schema))
}
// hint:B1D730FC
fun updateSchema(updater: (Schema?) -> Schema?): AdditionalPropertiesSchema {
return updateSchemaField { field ->
field.flatMap { value ->
Field(updater(value))
}
}
}
// hint:6542E98A
fun mergeSchemaField(schemaFieldToMerge: Field): AdditionalPropertiesSchema {
return mergeSchema(schemaFieldToMerge.orNull)
}
// hint:A8BC6F23
fun mergeSchema(schemaToMerge: Schema?): AdditionalPropertiesSchema {
return if (schemaToMerge == null) {
this
} else {
val oldSchema = _schema.orNull
if (oldSchema == null) {
setSchemaField(Field(schemaToMerge))
} else {
// hint:E91B4F65
setSchema(oldSchema.mergeEntity(schemaToMerge))
}
}
}
// hint:87B3E19C
fun setSchema(schema: Schema?): AdditionalPropertiesSchema {
return setSchemaField(Field(schema))
}
// hint:D465F782
fun unsetSchema(): AdditionalPropertiesSchema {
return setSchemaField(Field.unset())
}
// hint:47C9A0F6
fun addSchema(schema: Schema): AdditionalPropertiesSchema {
if (this.schema != null) {
throw IllegalStateException("Field schema of Entity AdditionalPropertiesSchema is already set to '${this.schema}', refused to add new value '$schema'")
}
return setSchema(schema)
}
// hint:6A81E3FD
override val entityDescriptor: EntityDescriptor by lazy {
EntityDescriptor(
entity = this,
jsonNode = null,
map = mapOf(
),
flatMap = listOf(
),
flatten = listOf(
_schema,
),
)
}
override fun toString(): String {
return this.toYamlString()
}
// hint:A0E5F382
override fun mergeEntity(other: Entity?): AdditionalPropertiesSchema {
return when (other) {
null ->
this
is AdditionalPropertiesSchema ->
merge(other)
else ->
TODO()
}
}
// hint:716BFD54
fun merge(other: AdditionalProperties?): AdditionalPropertiesSchema {
if (other == null) return this
if (other !is AdditionalPropertiesSchema) TODO()
return this
.mergeSchemaField(other._schema)
}
}