de.lancom.openapi.entity.AdditionalPropertiesReference.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.refs.Reference
import de.lancom.openapi.tools.toYamlString
// hint:9A1BF04C
@Suppress("PropertyName")
@JsonSerialize(using = AdditionalProperties.Companion.Serializer::class)
@JsonDeserialize(using = AdditionalProperties.Companion.Deserializer::class)
data class AdditionalPropertiesReference(
val _reference: Field?> = Field.unset(),
) : AdditionalProperties {
///////////////////////
//
// reference
//
///////////////////////
// hint:3A7F9B2E
val reference: Reference?
get() = _reference.orNull
// hint:F0C48D71
fun setReferenceField(reference: Field?>): AdditionalPropertiesReference {
return copy(_reference = reference)
}
// hint:8E56A4D9
fun updateReferenceField(updater: (Field?>) -> Field?>): AdditionalPropertiesReference {
return setReferenceField(updater(_reference))
}
// hint:B1D730FC
fun updateReference(updater: (Reference?) -> Reference?): AdditionalPropertiesReference {
return updateReferenceField { field ->
field.flatMap { value ->
Field(updater(value))
}
}
}
// hint:6542E98A
fun mergeReferenceField(referenceFieldToMerge: Field?>): AdditionalPropertiesReference {
return mergeReference(referenceFieldToMerge.orNull)
}
// hint:A8BC6F23
fun mergeReference(referenceToMerge: Reference?): AdditionalPropertiesReference {
return if (referenceToMerge == null) {
this
} else {
val oldReference = _reference.orNull
if (oldReference == null) {
setReferenceField(Field(referenceToMerge))
} else {
// hint:2F684DAC
setReference(referenceToMerge)
}
}
}
// hint:87B3E19C
fun setReference(reference: Reference?): AdditionalPropertiesReference {
return setReferenceField(Field(reference))
}
// hint:D465F782
fun unsetReference(): AdditionalPropertiesReference {
return setReferenceField(Field.unset())
}
// hint:47C9A0F6
fun addReference(reference: Reference): AdditionalPropertiesReference {
if (this.reference != null) {
throw IllegalStateException("Field reference of Entity AdditionalPropertiesReference is already set to '${this.reference}', refused to add new value '$reference'")
}
return setReference(reference)
}
// hint:6A81E3FD
override val entityDescriptor: EntityDescriptor by lazy {
EntityDescriptor(
entity = this,
jsonNode = null,
map = mapOf(
),
flatMap = listOf(
),
flatten = listOf(
_reference,
),
)
}
override fun toString(): String {
return this.toYamlString()
}
// hint:A0E5F382
override fun mergeEntity(other: Entity?): AdditionalPropertiesReference {
return when (other) {
null ->
this
is AdditionalPropertiesReference ->
merge(other)
else ->
TODO()
}
}
// hint:716BFD54
fun merge(other: AdditionalProperties?): AdditionalPropertiesReference {
if (other == null) return this
if (other !is AdditionalPropertiesReference) TODO()
return this
.mergeReferenceField(other._reference)
}
}