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

org.openapitools.client.infrastructure.OctetByteArray.kt Maven / Gradle / Ivy

Go to download

A demo for deployment to the Central Repository. A kotlin client library for OpenAPI Petstore by org.openapitools

The newest version!
package org.openapitools.client.infrastructure

import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*

@Serializable
class OctetByteArray(val value: ByteArray) {
    @Serializer(OctetByteArray::class)
    companion object : KSerializer {
        override val descriptor = PrimitiveSerialDescriptor("OctetByteArray", PrimitiveKind.STRING)
        override fun serialize(encoder: Encoder, obj: OctetByteArray) = encoder.encodeString(hex(obj.value))
        override fun deserialize(decoder: Decoder) = OctetByteArray(hex(decoder.decodeString()))
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other == null || this::class != other::class) return false
        other as OctetByteArray
        return value.contentEquals(other.value)
    }

    override fun hashCode(): Int {
        return value.contentHashCode()
    }

    override fun toString(): String {
        return "OctetByteArray(${hex(value)})"
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy