Coverage Summary for Class: CustomActionSerializer (com.ghost.serialization.integration.model)
| Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| CustomActionSerializer |
100%
(1/1)
|
88.9%
(8/9)
|
70%
(7/10)
|
84.4%
(38/45)
|
81%
(158/195)
|
@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.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 okio.ByteString
import okio.ByteString.Companion.encodeUtf8
/**
* High-performance serializer for [CustomAction].
* Generated by GhostSerialization. Do not modify manually.
*/
public object CustomActionSerializer : GhostSerializer<CustomAction> {
override val typeName: String = "CustomAction"
private val OPTIONS: JsonReaderOptions = JsonReaderOptions.of(0, 31, 128, false, "actionName")
private val H_ACTIONNAME: ByteString = "\"actionName\":".encodeUtf8()
private const val MASK_ACTIONNAME: Long = 1L
private const val MASK_REQUIRED_0: Long = 1L
private fun validateRequiredFields(mask0: Long, reader: GhostJsonReader) {
if ((mask0 and MASK_ACTIONNAME) == 0L) {
reader.throwError("Required field 'actionName' missing in JSON")
}
}
/**
* Robust deserialization for [CustomAction].
*/
override fun deserialize(reader: GhostJsonReader): CustomAction {
var actionNameValue: String? = null
var mask0 = 0L
reader.beginObject()
while (true) {
val index = reader.selectNameAndConsume(OPTIONS)
when (index) {
0 -> {
actionNameValue = reader.nextString()
mask0 = mask0 or MASK_ACTIONNAME
}
-1 -> break
-2 -> {
reader.skipValue()
}
}
}
reader.endObject()
validateRequiredFields(mask0, reader)
return CustomAction(
actionName = actionNameValue!!,
)
}
private fun validateRequiredFields(mask0: Long, reader: GhostJsonFlatReader) {
if ((mask0 and MASK_ACTIONNAME) == 0L) {
reader.throwError("Required field 'actionName' missing in JSON")
}
}
/**
* Robust deserialization for [CustomAction].
*/
override fun deserialize(reader: GhostJsonFlatReader): CustomAction {
var actionNameValue: String? = null
var mask0 = 0L
reader.beginObject()
while (true) {
val index = reader.selectNameAndConsume(OPTIONS)
when (index) {
0 -> {
actionNameValue = reader.nextString()
mask0 = mask0 or MASK_ACTIONNAME
}
-1 -> break
-2 -> {
reader.skipValue()
}
}
}
reader.endObject()
validateRequiredFields(mask0, reader)
return CustomAction(
actionName = actionNameValue!!,
)
}
override fun serialize(writer: GhostJsonWriter, `value`: CustomAction) {
writer.beginObject()
writer.name("type").value("CustomAction")
writer.writeField(H_ACTIONNAME, value.actionName)
writer.endObject()
}
override fun serialize(writer: GhostJsonFlatWriter, `value`: CustomAction) {
writer.beginObject()
writer.name("type").value("CustomAction")
writer.writeField(H_ACTIONNAME, value.actionName)
writer.endObject()
}
override fun warmUp() {
try {
val reader1 = GhostJsonReader("{\"actionName\":\"\"}".encodeToByteArray())
deserialize(reader1)
} catch (_: Exception) {
}
try {
val reader2 = GhostJsonFlatReader("{\"actionName\":\"\"}".encodeToByteArray())
deserialize(reader2)
} catch (_: Exception) {
}
}
}