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

Class Class, % Method, % Branch, % Line, % Instruction, %
GhostShape_SquareSerializer 100% (1/1) 88.9% (8/9) 70% (7/10) 84.4% (38/45) 80.6% (154/191)


 @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.endObject
 import com.ghost.serialization.parser.nextDouble
 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 [GhostShape.Square].
  * Generated by GhostSerialization. Do not modify manually.
  */
 public object GhostShape_SquareSerializer : GhostSerializer<GhostShape.Square> {
   override val typeName: String = "Square"
 
   private val OPTIONS: JsonReaderOptions = JsonReaderOptions.of(0, 31, 128, false, "side")
 
   private val H_SIDE: ByteString = "\"side\":".encodeUtf8()
 
   private const val MASK_SIDE: Long = 1L
 
   private const val MASK_REQUIRED_0: Long = 1L
 
   private fun validateRequiredFields(mask0: Long, reader: GhostJsonReader) {
     if ((mask0 and MASK_SIDE) == 0L) {
       reader.throwError("Required field 'side' missing in JSON")
     }
   }
 
   /**
    * Robust deserialization for [GhostShape.Square].
    */
   override fun deserialize(reader: GhostJsonReader): GhostShape.Square {
     var sideValue: Double = 0.0
     var mask0 = 0L
     reader.beginObject()
     while (true) {
       val index = reader.selectNameAndConsume(OPTIONS)
       when (index) {
         0 -> {
           sideValue = reader.nextDouble()
           mask0 = mask0 or MASK_SIDE
         }
         -1 -> break
         -2 -> {
           reader.skipValue()
         }
       }
     }
     reader.endObject()
     validateRequiredFields(mask0, reader)
     return GhostShape.Square(
       side = sideValue,
     )
   }
 
   private fun validateRequiredFields(mask0: Long, reader: GhostJsonFlatReader) {
     if ((mask0 and MASK_SIDE) == 0L) {
       reader.throwError("Required field 'side' missing in JSON")
     }
   }
 
   /**
    * Robust deserialization for [GhostShape.Square].
    */
   override fun deserialize(reader: GhostJsonFlatReader): GhostShape.Square {
     var sideValue: Double = 0.0
     var mask0 = 0L
     reader.beginObject()
     while (true) {
       val index = reader.selectNameAndConsume(OPTIONS)
       when (index) {
         0 -> {
           sideValue = reader.nextDouble()
           mask0 = mask0 or MASK_SIDE
         }
         -1 -> break
         -2 -> {
           reader.skipValue()
         }
       }
     }
     reader.endObject()
     validateRequiredFields(mask0, reader)
     return GhostShape.Square(
       side = sideValue,
     )
   }
 
   override fun serialize(writer: GhostJsonWriter, `value`: GhostShape.Square) {
     writer.beginObject()
     writer.name("type").value("Square")
     writer.writeField(H_SIDE, value.side)
     writer.endObject()
   }
 
   override fun serialize(writer: GhostJsonFlatWriter, `value`: GhostShape.Square) {
     writer.beginObject()
     writer.name("type").value("Square")
     writer.writeField(H_SIDE, value.side)
     writer.endObject()
   }
 
   override fun warmUp() {
     try {
       val reader1 = GhostJsonReader("{\"side\":0.0}".encodeToByteArray())
       deserialize(reader1)
     } catch (_: Exception) {
     }
     try {
       val reader2 = GhostJsonFlatReader("{\"side\":0.0}".encodeToByteArray())
       deserialize(reader2)
     } catch (_: Exception) {
     }
   }
 }