Coverage Summary for Class: WrappedKeysFixtureSerializer (com.ghost.serialization.integration.model)
| Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| WrappedKeysFixtureSerializer |
100%
(1/1)
|
88.9%
(8/9)
|
50%
(23/46)
|
78.5%
(84/107)
|
77.3%
(396/512)
|
@file:OptIn(InternalGhostApi::class)
package com.ghost.serialization.integration.model
import com.ghost.serialization.InternalGhostApi
import com.ghost.serialization.contract.GhostSerializer
import com.ghost.serialization.parser.GhostJsonFlatReader
import com.ghost.serialization.parser.GhostJsonReader
import com.ghost.serialization.parser.GhostWrappedKeysCapture
import com.ghost.serialization.parser.JsonReaderOptions
import com.ghost.serialization.parser.beginObject
import com.ghost.serialization.parser.captureWrappedKey
import com.ghost.serialization.parser.endObject
import com.ghost.serialization.parser.nextString
import com.ghost.serialization.parser.selectNameAndConsume
import com.ghost.serialization.parser.skipValue
import com.ghost.serialization.writer.GhostJsonFlatWriter
import com.ghost.serialization.writer.GhostJsonWriter
import kotlin.ByteArray
import kotlin.IntArray
import okio.ByteString
import okio.ByteString.Companion.encodeUtf8
/**
* High-performance serializer for [WrappedKeysFixture].
* Generated by GhostSerialization. Do not modify manually.
*/
public object WrappedKeysFixtureSerializer : GhostSerializer<WrappedKeysFixture> {
override val typeName: String = "WrappedKeysFixture"
private val OPTIONS: JsonReaderOptions =
JsonReaderOptions.of(0, 31, 128, false, "id", "extra1", "extra2", "extra3", "extra4")
private val H_EXTRA1: ByteString = "\"extra1\":".encodeUtf8()
private val H_EXTRA2: ByteString = "\"extra2\":".encodeUtf8()
private val H_EXTRA3: ByteString = "\"extra3\":".encodeUtf8()
private val H_EXTRA4: ByteString = "\"extra4\":".encodeUtf8()
private val H_ID: ByteString = "\"id\":".encodeUtf8()
private const val MASK_ID: Long = 1L
private const val MASK_EXTRAS: Long = 2L
private const val MASK_REQUIRED_0: Long = 3L
private val WRAPPED_KEY_LITERALS_EXTRAS: Array<ByteArray> = arrayOf(
"\"extra1\":".encodeToByteArray(),
"\"extra2\":".encodeToByteArray(),
"\"extra3\":".encodeToByteArray(),
"\"extra4\":".encodeToByteArray()
)
private val WRAPPED_OMIT_ABSENT_EXTRAS: IntArray = intArrayOf()
private fun validateRequiredFields(mask0: Long, reader: GhostJsonReader) {
if ((mask0 and MASK_REQUIRED_0) != MASK_REQUIRED_0) {
if ((mask0 and MASK_ID) == 0L) {
reader.throwError("Required field 'id' missing in JSON")
} else if ((mask0 and MASK_EXTRAS) == 0L) {
reader.throwError("Required field 'extras' missing in JSON")
}
}
}
/**
* Robust deserialization for [WrappedKeysFixture].
*/
override fun deserialize(reader: GhostJsonReader): WrappedKeysFixture {
var idValue: String? = null
var extrasValue: WireExtras? = null
val wrappedCapture_extras = GhostWrappedKeysCapture(4)
var mask0 = 0L
reader.beginObject()
while (true) {
val index = reader.selectNameAndConsume(OPTIONS)
when (index) {
0 -> {
idValue = reader.nextString()
mask0 = mask0 or MASK_ID
}
1 -> {
reader.captureWrappedKey(wrappedCapture_extras, 0)
}
2 -> {
reader.captureWrappedKey(wrappedCapture_extras, 1)
}
3 -> {
reader.captureWrappedKey(wrappedCapture_extras, 2)
}
4 -> {
reader.captureWrappedKey(wrappedCapture_extras, 3)
}
-1 -> break
-2 -> {
reader.skipValue()
}
}
}
reader.endObject()
val wrappedJson_extras = wrappedCapture_extras.materializeWrappedObject(WRAPPED_KEY_LITERALS_EXTRAS, false, WRAPPED_OMIT_ABSENT_EXTRAS)
if (wrappedJson_extras != null) {
val wrappedReader = GhostJsonReader(wrappedJson_extras)
extrasValue = WireExtrasSerializer.deserialize(wrappedReader)
mask0 = mask0 or MASK_EXTRAS
} else {
}
validateRequiredFields(mask0, reader)
return WrappedKeysFixture(
id = idValue!!,
extras = extrasValue!!,
)
}
private fun validateRequiredFields(mask0: Long, reader: GhostJsonFlatReader) {
if ((mask0 and MASK_REQUIRED_0) != MASK_REQUIRED_0) {
if ((mask0 and MASK_ID) == 0L) {
reader.throwError("Required field 'id' missing in JSON")
} else if ((mask0 and MASK_EXTRAS) == 0L) {
reader.throwError("Required field 'extras' missing in JSON")
}
}
}
/**
* Robust deserialization for [WrappedKeysFixture].
*/
override fun deserialize(reader: GhostJsonFlatReader): WrappedKeysFixture {
var idValue: String? = null
var extrasValue: WireExtras? = null
val wrappedCapture_extras = GhostWrappedKeysCapture(4)
var mask0 = 0L
reader.beginObject()
while (true) {
val index = reader.selectNameAndConsume(OPTIONS)
when (index) {
0 -> {
idValue = reader.nextString()
mask0 = mask0 or MASK_ID
}
1 -> {
reader.captureWrappedKey(wrappedCapture_extras, 0)
}
2 -> {
reader.captureWrappedKey(wrappedCapture_extras, 1)
}
3 -> {
reader.captureWrappedKey(wrappedCapture_extras, 2)
}
4 -> {
reader.captureWrappedKey(wrappedCapture_extras, 3)
}
-1 -> break
-2 -> {
reader.skipValue()
}
}
}
reader.endObject()
val wrappedJson_extras = wrappedCapture_extras.materializeWrappedObject(WRAPPED_KEY_LITERALS_EXTRAS, false, WRAPPED_OMIT_ABSENT_EXTRAS)
if (wrappedJson_extras != null) {
val wrappedReader = GhostJsonFlatReader(wrappedJson_extras)
extrasValue = WireExtrasSerializer.deserialize(wrappedReader)
mask0 = mask0 or MASK_EXTRAS
} else {
}
validateRequiredFields(mask0, reader)
return WrappedKeysFixture(
id = idValue!!,
extras = extrasValue!!,
)
}
override fun serialize(writer: GhostJsonWriter, `value`: WrappedKeysFixture) {
writer.beginObject()
writer.writeField(H_ID, value.id)
if (value.extras.extra1 != null) {
writer.writeNameRaw(H_EXTRA1)
writer.value(value.extras.extra1)
}
if (value.extras.extra2 != null) {
writer.writeNameRaw(H_EXTRA2)
writer.value(value.extras.extra2)
}
if (value.extras.extra3 != null) {
writer.writeNameRaw(H_EXTRA3)
writer.value(value.extras.extra3)
}
if (value.extras.extra4 != null) {
writer.writeNameRaw(H_EXTRA4)
writer.value(value.extras.extra4)
}
writer.endObject()
}
override fun serialize(writer: GhostJsonFlatWriter, `value`: WrappedKeysFixture) {
writer.beginObject()
writer.writeField(H_ID, value.id)
if (value.extras.extra1 != null) {
writer.writeNameRaw(H_EXTRA1)
writer.value(value.extras.extra1)
}
if (value.extras.extra2 != null) {
writer.writeNameRaw(H_EXTRA2)
writer.value(value.extras.extra2)
}
if (value.extras.extra3 != null) {
writer.writeNameRaw(H_EXTRA3)
writer.value(value.extras.extra3)
}
if (value.extras.extra4 != null) {
writer.writeNameRaw(H_EXTRA4)
writer.value(value.extras.extra4)
}
writer.endObject()
}
override fun warmUp() {
try {
val reader1 = GhostJsonReader("{\"id\":\"\",\"extras\":{}}".encodeToByteArray())
deserialize(reader1)
} catch (_: Exception) {
}
try {
val reader2 = GhostJsonFlatReader("{\"id\":\"\",\"extras\":{}}".encodeToByteArray())
deserialize(reader2)
} catch (_: Exception) {
}
}
}