Coverage Summary for Class: CoercionStressModelSerializer (com.ghost.serialization.integration.model)
| Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| CoercionStressModelSerializer |
100%
(1/1)
|
77.8%
(7/9)
|
36.4%
(16/44)
|
65%
(78/120)
|
52.3%
(283/541)
|
@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.nextBoolean
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 [CoercionStressModel].
* Generated by GhostSerialization. Do not modify manually.
*/
public object CoercionStressModelSerializer : GhostSerializer<CoercionStressModel> {
override val typeName: String = "CoercionStressModel"
private val OPTIONS: JsonReaderOptions =
JsonReaderOptions.of(4, 31, 128, false, "b1", "b2", "b3", "b4", "b5", "b6")
private val H_B1: ByteString = "\"b1\":".encodeUtf8()
private val H_B2: ByteString = "\"b2\":".encodeUtf8()
private val H_B3: ByteString = "\"b3\":".encodeUtf8()
private val H_B4: ByteString = "\"b4\":".encodeUtf8()
private val H_B5: ByteString = "\"b5\":".encodeUtf8()
private val H_B6: ByteString = "\"b6\":".encodeUtf8()
private const val MASK_B1: Long = 1L
private const val MASK_B2: Long = 2L
private const val MASK_B3: Long = 4L
private const val MASK_B4: Long = 8L
private const val MASK_B5: Long = 16L
private const val MASK_B6: Long = 32L
private const val MASK_REQUIRED_0: Long = 63L
private fun validateRequiredFields(mask0: Long, reader: GhostJsonReader) {
if ((mask0 and MASK_REQUIRED_0) != MASK_REQUIRED_0) {
if ((mask0 and MASK_B1) == 0L) {
reader.throwError("Required field 'b1' missing in JSON")
} else if ((mask0 and MASK_B2) == 0L) {
reader.throwError("Required field 'b2' missing in JSON")
} else if ((mask0 and MASK_B3) == 0L) {
reader.throwError("Required field 'b3' missing in JSON")
} else if ((mask0 and MASK_B4) == 0L) {
reader.throwError("Required field 'b4' missing in JSON")
} else if ((mask0 and MASK_B5) == 0L) {
reader.throwError("Required field 'b5' missing in JSON")
} else if ((mask0 and MASK_B6) == 0L) {
reader.throwError("Required field 'b6' missing in JSON")
}
}
}
/**
* Robust deserialization for [CoercionStressModel].
*/
override fun deserialize(reader: GhostJsonReader): CoercionStressModel {
var b1Value: Boolean = false
var b2Value: Boolean = false
var b3Value: Boolean = false
var b4Value: Boolean = false
var b5Value: Boolean = false
var b6Value: Boolean = false
var mask0 = 0L
reader.beginObject()
while (true) {
val index = reader.selectNameAndConsume(OPTIONS)
when (index) {
0 -> {
b1Value = reader.nextBoolean()
mask0 = mask0 or MASK_B1
}
1 -> {
b2Value = reader.nextBoolean()
mask0 = mask0 or MASK_B2
}
2 -> {
b3Value = reader.nextBoolean()
mask0 = mask0 or MASK_B3
}
3 -> {
b4Value = reader.nextBoolean()
mask0 = mask0 or MASK_B4
}
4 -> {
b5Value = reader.nextBoolean()
mask0 = mask0 or MASK_B5
}
5 -> {
b6Value = reader.nextBoolean()
mask0 = mask0 or MASK_B6
}
-1 -> break
-2 -> {
reader.skipValue()
}
}
}
reader.endObject()
validateRequiredFields(mask0, reader)
return CoercionStressModel(
b1 = b1Value,
b2 = b2Value,
b3 = b3Value,
b4 = b4Value,
b5 = b5Value,
b6 = b6Value,
)
}
private fun validateRequiredFields(mask0: Long, reader: GhostJsonFlatReader) {
if ((mask0 and MASK_REQUIRED_0) != MASK_REQUIRED_0) {
if ((mask0 and MASK_B1) == 0L) {
reader.throwError("Required field 'b1' missing in JSON")
} else if ((mask0 and MASK_B2) == 0L) {
reader.throwError("Required field 'b2' missing in JSON")
} else if ((mask0 and MASK_B3) == 0L) {
reader.throwError("Required field 'b3' missing in JSON")
} else if ((mask0 and MASK_B4) == 0L) {
reader.throwError("Required field 'b4' missing in JSON")
} else if ((mask0 and MASK_B5) == 0L) {
reader.throwError("Required field 'b5' missing in JSON")
} else if ((mask0 and MASK_B6) == 0L) {
reader.throwError("Required field 'b6' missing in JSON")
}
}
}
/**
* Robust deserialization for [CoercionStressModel].
*/
override fun deserialize(reader: GhostJsonFlatReader): CoercionStressModel {
var b1Value: Boolean = false
var b2Value: Boolean = false
var b3Value: Boolean = false
var b4Value: Boolean = false
var b5Value: Boolean = false
var b6Value: Boolean = false
var mask0 = 0L
reader.beginObject()
while (true) {
val index = reader.selectNameAndConsume(OPTIONS)
when (index) {
0 -> {
b1Value = reader.nextBoolean()
mask0 = mask0 or MASK_B1
}
1 -> {
b2Value = reader.nextBoolean()
mask0 = mask0 or MASK_B2
}
2 -> {
b3Value = reader.nextBoolean()
mask0 = mask0 or MASK_B3
}
3 -> {
b4Value = reader.nextBoolean()
mask0 = mask0 or MASK_B4
}
4 -> {
b5Value = reader.nextBoolean()
mask0 = mask0 or MASK_B5
}
5 -> {
b6Value = reader.nextBoolean()
mask0 = mask0 or MASK_B6
}
-1 -> break
-2 -> {
reader.skipValue()
}
}
}
reader.endObject()
validateRequiredFields(mask0, reader)
return CoercionStressModel(
b1 = b1Value,
b2 = b2Value,
b3 = b3Value,
b4 = b4Value,
b5 = b5Value,
b6 = b6Value,
)
}
override fun serialize(writer: GhostJsonWriter, `value`: CoercionStressModel) {
writer.beginObject()
writer.writeField(H_B1, value.b1)
writer.writeField(H_B2, value.b2)
writer.writeField(H_B3, value.b3)
writer.writeField(H_B4, value.b4)
writer.writeField(H_B5, value.b5)
writer.writeField(H_B6, value.b6)
writer.endObject()
}
override fun serialize(writer: GhostJsonFlatWriter, `value`: CoercionStressModel) {
writer.beginObject()
writer.writeField(H_B1, value.b1)
writer.writeField(H_B2, value.b2)
writer.writeField(H_B3, value.b3)
writer.writeField(H_B4, value.b4)
writer.writeField(H_B5, value.b5)
writer.writeField(H_B6, value.b6)
writer.endObject()
}
override fun warmUp() {
try {
val reader1 = GhostJsonReader("{\"b1\":false,\"b2\":false,\"b3\":false,\"b4\":false,\"b5\":false,\"b6\":false}".encodeToByteArray())
deserialize(reader1)
} catch (_: Exception) {
}
try {
val reader2 = GhostJsonFlatReader("{\"b1\":false,\"b2\":false,\"b3\":false,\"b4\":false,\"b5\":false,\"b6\":false}".encodeToByteArray())
deserialize(reader2)
} catch (_: Exception) {
}
}
}