Coverage Summary for Class: OmitIfEmptyWrappedKeysFixtureSerializer (com.ghost.serialization.integration.model)
| Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| OmitIfEmptyWrappedKeysFixtureSerializer |
100%
(1/1)
|
88.9%
(8/9)
|
31%
(13/42)
|
60%
(63/105)
|
55.8%
(268/480)
|
@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.consumeNull
import com.ghost.serialization.parser.endObject
import com.ghost.serialization.parser.isNextNullValue
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 [OmitIfEmptyWrappedKeysFixture].
* Generated by GhostSerialization. Do not modify manually.
*/
public object OmitIfEmptyWrappedKeysFixtureSerializer : GhostSerializer<OmitIfEmptyWrappedKeysFixture> {
override val typeName: String = "OmitIfEmptyWrappedKeysFixture"
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 = 1L
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_ID) == 0L) {
reader.throwError("Required field 'id' missing in JSON")
}
}
/**
* Robust deserialization for [OmitIfEmptyWrappedKeysFixture].
*/
override fun deserialize(reader: GhostJsonReader): OmitIfEmptyWrappedKeysFixture {
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, true, WRAPPED_OMIT_ABSENT_EXTRAS)
if (wrappedJson_extras != null) {
val wrappedReader = GhostJsonReader(wrappedJson_extras)
extrasValue = WireExtrasSerializer.deserialize(wrappedReader)
mask0 = mask0 or MASK_EXTRAS
} else {
extrasValue = null
}
validateRequiredFields(mask0, reader)
return OmitIfEmptyWrappedKeysFixture(
id = idValue!!,
extras = extrasValue,
)
}
private fun validateRequiredFields(mask0: Long, reader: GhostJsonFlatReader) {
if ((mask0 and MASK_ID) == 0L) {
reader.throwError("Required field 'id' missing in JSON")
}
}
/**
* Robust deserialization for [OmitIfEmptyWrappedKeysFixture].
*/
override fun deserialize(reader: GhostJsonFlatReader): OmitIfEmptyWrappedKeysFixture {
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, true, WRAPPED_OMIT_ABSENT_EXTRAS)
if (wrappedJson_extras != null) {
val wrappedReader = GhostJsonFlatReader(wrappedJson_extras)
extrasValue = WireExtrasSerializer.deserialize(wrappedReader)
mask0 = mask0 or MASK_EXTRAS
} else {
extrasValue = null
}
validateRequiredFields(mask0, reader)
return OmitIfEmptyWrappedKeysFixture(
id = idValue!!,
extras = extrasValue,
)
}
override fun serialize(writer: GhostJsonWriter, `value`: OmitIfEmptyWrappedKeysFixture) {
writer.beginObject()
writer.writeField(H_ID, value.id)
if (value.extras != null) {
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`: OmitIfEmptyWrappedKeysFixture) {
writer.beginObject()
writer.writeField(H_ID, value.id)
if (value.extras != null) {
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\":\"\"}".encodeToByteArray())
deserialize(reader1)
} catch (_: Exception) {
}
try {
val reader2 = GhostJsonFlatReader("{\"id\":\"\"}".encodeToByteArray())
deserialize(reader2)
} catch (_: Exception) {
}
}
}