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

Class Class, % Method, % Branch, % Line, % Instruction, %
GhostEnumWrapperSerializer 100% (1/1) 77.8% (7/9) 37.5% (9/24) 62.1% (41/66) 59.8% (174/291)


 @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.beginObject
 import com.ghost.serialization.parser.consumeNull
 import com.ghost.serialization.parser.endObject
 import com.ghost.serialization.parser.isNextNullValue
 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 okio.ByteString
 import okio.ByteString.Companion.encodeUtf8
 
 /**
  * High-performance serializer for [GhostEnumWrapper].
  * Generated by GhostSerialization. Do not modify manually.
  */
 public object GhostEnumWrapperSerializer : GhostSerializer<GhostEnumWrapper> {
   override val typeName: String = "GhostEnumWrapper"
 
   private val OPTIONS: JsonReaderOptions =
       JsonReaderOptions.of(0, 31, 128, false, "status", "optionalStatus")
 
   private val H_OPTIONALSTATUS: ByteString = "\"optionalStatus\":".encodeUtf8()
 
   private val H_STATUS: ByteString = "\"status\":".encodeUtf8()
 
   private const val MASK_STATUS: Long = 1L
 
   private const val MASK_OPTIONALSTATUS: Long = 2L
 
   private const val MASK_REQUIRED_0: Long = 1L
 
   private const val MASK_OPTS_OPTIONALSTATUS: Long = 2L
 
   private fun validateRequiredFields(mask0: Long, reader: GhostJsonReader) {
     if ((mask0 and MASK_STATUS) == 0L) {
       reader.throwError("Required field 'status' missing in JSON")
     }
   }
 
   /**
    * Robust deserialization for [GhostEnumWrapper].
    */
   override fun deserialize(reader: GhostJsonReader): GhostEnumWrapper {
     var statusValue: GhostStandardsEnum? = null
     var optionalStatusValue: GhostStandardsEnum? = null
     var mask0 = 0L
     reader.beginObject()
     while (true) {
       val index = reader.selectNameAndConsume(OPTIONS)
       when (index) {
         0 -> {
           statusValue = GhostStandardsEnumSerializer.deserialize(reader)
           mask0 = mask0 or MASK_STATUS
         }
         1 -> {
           optionalStatusValue = if (reader.isNextNullValue()) { reader.consumeNull(); null } else GhostStandardsEnumSerializer.deserialize(reader)
           mask0 = mask0 or MASK_OPTIONALSTATUS
         }
         -1 -> break
         -2 -> {
           reader.skipValue()
         }
       }
     }
     reader.endObject()
     validateRequiredFields(mask0, reader)
     if ((mask0 and MASK_OPTS_OPTIONALSTATUS) == MASK_OPTS_OPTIONALSTATUS) {
       return GhostEnumWrapper(
         status = statusValue!!,
         optionalStatus = optionalStatusValue,
       )
     }
     return GhostEnumWrapper(
       status = statusValue!!,
     )
   }
 
   private fun validateRequiredFields(mask0: Long, reader: GhostJsonFlatReader) {
     if ((mask0 and MASK_STATUS) == 0L) {
       reader.throwError("Required field 'status' missing in JSON")
     }
   }
 
   /**
    * Robust deserialization for [GhostEnumWrapper].
    */
   override fun deserialize(reader: GhostJsonFlatReader): GhostEnumWrapper {
     var statusValue: GhostStandardsEnum? = null
     var optionalStatusValue: GhostStandardsEnum? = null
     var mask0 = 0L
     reader.beginObject()
     while (true) {
       val index = reader.selectNameAndConsume(OPTIONS)
       when (index) {
         0 -> {
           statusValue = GhostStandardsEnumSerializer.deserialize(reader)
           mask0 = mask0 or MASK_STATUS
         }
         1 -> {
           optionalStatusValue = if (reader.isNextNullValue()) { reader.consumeNull(); null } else GhostStandardsEnumSerializer.deserialize(reader)
           mask0 = mask0 or MASK_OPTIONALSTATUS
         }
         -1 -> break
         -2 -> {
           reader.skipValue()
         }
       }
     }
     reader.endObject()
     validateRequiredFields(mask0, reader)
     if ((mask0 and MASK_OPTS_OPTIONALSTATUS) == MASK_OPTS_OPTIONALSTATUS) {
       return GhostEnumWrapper(
         status = statusValue!!,
         optionalStatus = optionalStatusValue,
       )
     }
     return GhostEnumWrapper(
       status = statusValue!!,
     )
   }
 
   override fun serialize(writer: GhostJsonWriter, `value`: GhostEnumWrapper) {
     writer.beginObject()
     writer.writeNameRaw(H_STATUS)
     GhostStandardsEnumSerializer.serialize(writer, value.status)
     if (value.optionalStatus != null) {
       writer.writeNameRaw(H_OPTIONALSTATUS)
       GhostStandardsEnumSerializer.serialize(writer, value.optionalStatus)
     }
     writer.endObject()
   }
 
   override fun serialize(writer: GhostJsonFlatWriter, `value`: GhostEnumWrapper) {
     writer.beginObject()
     writer.writeNameRaw(H_STATUS)
     GhostStandardsEnumSerializer.serialize(writer, value.status)
     if (value.optionalStatus != null) {
       writer.writeNameRaw(H_OPTIONALSTATUS)
       GhostStandardsEnumSerializer.serialize(writer, value.optionalStatus)
     }
     writer.endObject()
   }
 
   override fun warmUp() {
     try {
       val reader1 = GhostJsonReader("{\"status\":{}}".encodeToByteArray())
       deserialize(reader1)
     } catch (_: Exception) {
     }
     try {
       val reader2 = GhostJsonFlatReader("{\"status\":{}}".encodeToByteArray())
       deserialize(reader2)
     } catch (_: Exception) {
     }
   }
 }