
com.avsystem.commons.serialization.DefaultCaseObjectInput.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-core_2.13 Show documentation
Show all versions of commons-core_2.13 Show documentation
AVSystem commons library for Scala
package com.avsystem.commons
package serialization
import com.avsystem.commons.serialization.GenCodec.ReadFailure
final class DefaultCaseObjectInput(firstField: FieldInput, actualInput: ObjectInput, caseFieldName: String)
extends ObjectInput {
override def knownSize: Int = actualInput.knownSize
private[this] var atFirstField = true
def hasNext: Boolean = atFirstField || actualInput.hasNext
def nextField(): FieldInput =
if (atFirstField) {
atFirstField = false
firstField
} else {
val field = actualInput.nextField()
if (field.fieldName == caseFieldName) {
throw new ReadFailure(s"$caseFieldName field found too far into the object")
}
field
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy