Coverage Summary for Class: RepeatedWrappedKeysFixtureSerializer (com.ghost.serialization.integration.model)

Class Class, % Method, % Branch, % Line, % Instruction, %
RepeatedWrappedKeysFixtureSerializer 100% (1/1) 66.7% (6/9) 36.8% (14/38) 58.7% (71/121) 55.8% (331/593)


 @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 [RepeatedWrappedKeysFixture].
  * Generated by GhostSerialization. Do not modify manually.
  */
 public object RepeatedWrappedKeysFixtureSerializer : GhostSerializer<RepeatedWrappedKeysFixture> {
   override val typeName: String = "RepeatedWrappedKeysFixture"
 
   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_EXTRAS12: Long = 2L
 
   private const val MASK_EXTRAS34: Long = 4L
 
   private const val MASK_REQUIRED_0: Long = 7L
 
   private val WRAPPED_KEY_LITERALS_EXTRAS12: Array<ByteArray> = arrayOf(
           "\"extra1\":".encodeToByteArray(),
           "\"extra2\":".encodeToByteArray()
       )
 
   private val WRAPPED_OMIT_ABSENT_EXTRAS12: IntArray = intArrayOf()
 
   private val WRAPPED_KEY_LITERALS_EXTRAS34: Array<ByteArray> = arrayOf(
           "\"extra3\":".encodeToByteArray(),
           "\"extra4\":".encodeToByteArray()
       )
 
   private val WRAPPED_OMIT_ABSENT_EXTRAS34: 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_EXTRAS12) == 0L) {
         reader.throwError("Required field 'extras12' missing in JSON")
       } else if ((mask0 and MASK_EXTRAS34) == 0L) {
         reader.throwError("Required field 'extras34' missing in JSON")
       }
     }
   }
 
   /**
    * Robust deserialization for [RepeatedWrappedKeysFixture].
    */
   override fun deserialize(reader: GhostJsonReader): RepeatedWrappedKeysFixture {
     var idValue: String? = null
     var extras12Value: WireExtras12? = null
     var extras34Value: WireExtras34? = null
     val wrappedCapture_extras12 = GhostWrappedKeysCapture(2)
     val wrappedCapture_extras34 = GhostWrappedKeysCapture(2)
     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_extras12, 0)
         }
         2 -> {
           reader.captureWrappedKey(wrappedCapture_extras12, 1)
         }
         3 -> {
           reader.captureWrappedKey(wrappedCapture_extras34, 0)
         }
         4 -> {
           reader.captureWrappedKey(wrappedCapture_extras34, 1)
         }
         -1 -> break
         -2 -> {
           reader.skipValue()
         }
       }
     }
     reader.endObject()
     val wrappedJson_extras12 = wrappedCapture_extras12.materializeWrappedObject(WRAPPED_KEY_LITERALS_EXTRAS12, false, WRAPPED_OMIT_ABSENT_EXTRAS12)
     if (wrappedJson_extras12 != null) {
       val wrappedReader = GhostJsonReader(wrappedJson_extras12)
       extras12Value = WireExtras12Serializer.deserialize(wrappedReader)
       mask0 = mask0 or MASK_EXTRAS12
     } else {
     }
     val wrappedJson_extras34 = wrappedCapture_extras34.materializeWrappedObject(WRAPPED_KEY_LITERALS_EXTRAS34, false, WRAPPED_OMIT_ABSENT_EXTRAS34)
     if (wrappedJson_extras34 != null) {
       val wrappedReader = GhostJsonReader(wrappedJson_extras34)
       extras34Value = WireExtras34Serializer.deserialize(wrappedReader)
       mask0 = mask0 or MASK_EXTRAS34
     } else {
     }
     validateRequiredFields(mask0, reader)
     return RepeatedWrappedKeysFixture(
       id = idValue!!,
       extras12 = extras12Value!!,
       extras34 = extras34Value!!,
     )
   }
 
   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_EXTRAS12) == 0L) {
         reader.throwError("Required field 'extras12' missing in JSON")
       } else if ((mask0 and MASK_EXTRAS34) == 0L) {
         reader.throwError("Required field 'extras34' missing in JSON")
       }
     }
   }
 
   /**
    * Robust deserialization for [RepeatedWrappedKeysFixture].
    */
   override fun deserialize(reader: GhostJsonFlatReader): RepeatedWrappedKeysFixture {
     var idValue: String? = null
     var extras12Value: WireExtras12? = null
     var extras34Value: WireExtras34? = null
     val wrappedCapture_extras12 = GhostWrappedKeysCapture(2)
     val wrappedCapture_extras34 = GhostWrappedKeysCapture(2)
     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_extras12, 0)
         }
         2 -> {
           reader.captureWrappedKey(wrappedCapture_extras12, 1)
         }
         3 -> {
           reader.captureWrappedKey(wrappedCapture_extras34, 0)
         }
         4 -> {
           reader.captureWrappedKey(wrappedCapture_extras34, 1)
         }
         -1 -> break
         -2 -> {
           reader.skipValue()
         }
       }
     }
     reader.endObject()
     val wrappedJson_extras12 = wrappedCapture_extras12.materializeWrappedObject(WRAPPED_KEY_LITERALS_EXTRAS12, false, WRAPPED_OMIT_ABSENT_EXTRAS12)
     if (wrappedJson_extras12 != null) {
       val wrappedReader = GhostJsonFlatReader(wrappedJson_extras12)
       extras12Value = WireExtras12Serializer.deserialize(wrappedReader)
       mask0 = mask0 or MASK_EXTRAS12
     } else {
     }
     val wrappedJson_extras34 = wrappedCapture_extras34.materializeWrappedObject(WRAPPED_KEY_LITERALS_EXTRAS34, false, WRAPPED_OMIT_ABSENT_EXTRAS34)
     if (wrappedJson_extras34 != null) {
       val wrappedReader = GhostJsonFlatReader(wrappedJson_extras34)
       extras34Value = WireExtras34Serializer.deserialize(wrappedReader)
       mask0 = mask0 or MASK_EXTRAS34
     } else {
     }
     validateRequiredFields(mask0, reader)
     return RepeatedWrappedKeysFixture(
       id = idValue!!,
       extras12 = extras12Value!!,
       extras34 = extras34Value!!,
     )
   }
 
   override fun serialize(writer: GhostJsonWriter, `value`: RepeatedWrappedKeysFixture) {
     writer.beginObject()
     writer.writeField(H_ID, value.id)
     writer.writeNameRaw(H_EXTRA1)
     writer.value(value.extras12.extra1)
     writer.writeNameRaw(H_EXTRA2)
     writer.value(value.extras12.extra2)
     writer.writeNameRaw(H_EXTRA3)
     writer.value(value.extras34.extra3)
     writer.writeNameRaw(H_EXTRA4)
     writer.value(value.extras34.extra4)
     writer.endObject()
   }
 
   override fun serialize(writer: GhostJsonFlatWriter, `value`: RepeatedWrappedKeysFixture) {
     writer.beginObject()
     writer.writeField(H_ID, value.id)
     writer.writeNameRaw(H_EXTRA1)
     writer.value(value.extras12.extra1)
     writer.writeNameRaw(H_EXTRA2)
     writer.value(value.extras12.extra2)
     writer.writeNameRaw(H_EXTRA3)
     writer.value(value.extras34.extra3)
     writer.writeNameRaw(H_EXTRA4)
     writer.value(value.extras34.extra4)
     writer.endObject()
   }
 
   override fun warmUp() {
     try {
       val reader1 = GhostJsonReader("{\"id\":\"\",\"extras12\":{},\"extras34\":{}}".encodeToByteArray())
       deserialize(reader1)
     } catch (_: Exception) {
     }
     try {
       val reader2 = GhostJsonFlatReader("{\"id\":\"\",\"extras12\":{},\"extras34\":{}}".encodeToByteArray())
       deserialize(reader2)
     } catch (_: Exception) {
     }
   }
 }