Coverage Summary for Class: ProtoValueClassCollectionFixtureSerializer (com.ghost.serialization.integration.model)
| Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| ProtoValueClassCollectionFixtureSerializer |
100%
(1/1)
|
90%
(9/10)
|
38.9%
(14/36)
|
69%
(60/87)
|
70%
(357/510)
|
@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.JsonReaderOptions
import com.ghost.serialization.parser.beginArray
import com.ghost.serialization.parser.beginObject
import com.ghost.serialization.parser.endArray
import com.ghost.serialization.parser.endObject
import com.ghost.serialization.parser.nextKey
import com.ghost.serialization.parser.nextLong
import com.ghost.serialization.parser.readList
import com.ghost.serialization.parser.readMap
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.collections.List
import kotlin.collections.Map
import okio.ByteString
import okio.ByteString.Companion.encodeUtf8
/**
* High-performance serializer for [ProtoValueClassCollectionFixture].
* Generated by GhostSerialization. Do not modify manually.
*/
public object ProtoValueClassCollectionFixtureSerializer : GhostSerializer<ProtoValueClassCollectionFixture> {
override val typeName: String = "ProtoValueClassCollectionFixture"
override val isProto: Boolean = true
private val OPTIONS: JsonReaderOptions =
JsonReaderOptions.of(0, 31, 128, false, "ids", "accounts")
private val H_ACCOUNTS: ByteString = "\"accounts\":".encodeUtf8()
private val H_IDS: ByteString = "\"ids\":".encodeUtf8()
private const val MASK_IDS: Long = 1L
private const val MASK_ACCOUNTS: Long = 2L
private const val MASK_REQUIRED_0: Long = 3L
private fun validateRequiredFields(mask0: Long, reader: GhostJsonReader) {
if ((mask0 and MASK_REQUIRED_0) != MASK_REQUIRED_0) {
if ((mask0 and MASK_IDS) == 0L) {
reader.throwError("Required field 'ids' missing in JSON")
} else if ((mask0 and MASK_ACCOUNTS) == 0L) {
reader.throwError("Required field 'accounts' missing in JSON")
}
}
}
/**
* Robust deserialization for [ProtoValueClassCollectionFixture].
*/
override fun deserialize(reader: GhostJsonReader): ProtoValueClassCollectionFixture {
var idsValue: List<ProtoAccountId>? = null
var accountsValue: Map<String, ProtoAccountId>? = null
var mask0 = 0L
reader.beginObject()
while (true) {
val index = reader.selectNameAndConsume(OPTIONS)
when (index) {
0 -> {
idsValue = reader.readList { ProtoAccountId(run { val __c = reader.coerceStringsToNumbers; reader.coerceStringsToNumbers = true; val __v = reader.nextLong(); reader.coerceStringsToNumbers = __c; __v }) }
mask0 = mask0 or MASK_IDS
}
1 -> {
accountsValue = reader.readMap({ reader.nextKey()!! }) { ProtoAccountId(run { val __c = reader.coerceStringsToNumbers; reader.coerceStringsToNumbers = true; val __v = reader.nextLong(); reader.coerceStringsToNumbers = __c; __v }) }
mask0 = mask0 or MASK_ACCOUNTS
}
-1 -> break
-2 -> {
reader.skipValue()
}
}
}
reader.endObject()
validateRequiredFields(mask0, reader)
return ProtoValueClassCollectionFixture(
ids = idsValue!!,
accounts = accountsValue!!,
)
}
private fun validateRequiredFields(mask0: Long, reader: GhostJsonFlatReader) {
if ((mask0 and MASK_REQUIRED_0) != MASK_REQUIRED_0) {
if ((mask0 and MASK_IDS) == 0L) {
reader.throwError("Required field 'ids' missing in JSON")
} else if ((mask0 and MASK_ACCOUNTS) == 0L) {
reader.throwError("Required field 'accounts' missing in JSON")
}
}
}
/**
* Robust deserialization for [ProtoValueClassCollectionFixture].
*/
override fun deserialize(reader: GhostJsonFlatReader): ProtoValueClassCollectionFixture {
var idsValue: List<ProtoAccountId>? = null
var accountsValue: Map<String, ProtoAccountId>? = null
var mask0 = 0L
reader.beginObject()
while (true) {
val index = reader.selectNameAndConsume(OPTIONS)
when (index) {
0 -> {
idsValue = reader.readList { ProtoAccountId(run { val __c = reader.coerceStringsToNumbers; reader.coerceStringsToNumbers = true; val __v = reader.nextLong(); reader.coerceStringsToNumbers = __c; __v }) }
mask0 = mask0 or MASK_IDS
}
1 -> {
accountsValue = reader.readMap({ reader.nextKey()!! }) { ProtoAccountId(run { val __c = reader.coerceStringsToNumbers; reader.coerceStringsToNumbers = true; val __v = reader.nextLong(); reader.coerceStringsToNumbers = __c; __v }) }
mask0 = mask0 or MASK_ACCOUNTS
}
-1 -> break
-2 -> {
reader.skipValue()
}
}
}
reader.endObject()
validateRequiredFields(mask0, reader)
return ProtoValueClassCollectionFixture(
ids = idsValue!!,
accounts = accountsValue!!,
)
}
override fun serialize(writer: GhostJsonWriter, `value`: ProtoValueClassCollectionFixture) {
writer.beginObject()
if (value.ids.isNotEmpty()) {
writer.writeNameRaw(H_IDS)
writer.beginArray()
val size0 = value.ids.size
for (i0 in 0 until size0) {
val item0 = value.ids[i0]
writer.value(item0.value.toString())
}
writer.endArray()
}
if (value.accounts.isNotEmpty()) {
writer.writeNameRaw(H_ACCOUNTS)
writer.beginObject()
for ((mapKey1, mapVal1) in value.accounts) {
writer.name(mapKey1)
writer.value(mapVal1.value.toString())
}
writer.endObject()
}
writer.endObject()
}
override fun serialize(writer: GhostJsonFlatWriter, `value`: ProtoValueClassCollectionFixture) {
writer.beginObject()
if (value.ids.isNotEmpty()) {
writer.writeNameRaw(H_IDS)
writer.beginArray()
val size0 = value.ids.size
for (i0 in 0 until size0) {
val item0 = value.ids[i0]
writer.value(item0.value.toString())
}
writer.endArray()
}
if (value.accounts.isNotEmpty()) {
writer.writeNameRaw(H_ACCOUNTS)
writer.beginObject()
for ((mapKey1, mapVal1) in value.accounts) {
writer.name(mapKey1)
writer.value(mapVal1.value.toString())
}
writer.endObject()
}
writer.endObject()
}
override fun warmUp() {
try {
val reader1 = GhostJsonReader("{\"ids\":[],\"accounts\":{}}".encodeToByteArray())
deserialize(reader1)
} catch (_: Exception) {
}
try {
val reader2 = GhostJsonFlatReader("{\"ids\":[],\"accounts\":{}}".encodeToByteArray())
deserialize(reader2)
} catch (_: Exception) {
}
}
}