private[this] def genReadValue()

in scrooge-generator/src/main/scala/com/twitter/scrooge/backend/StructTemplate.scala [159:184]


  private[this] def genReadValue(fieldType: FieldType, protoName: String): CodeFragment = {
    fieldType match {
      case at: AnnotatedFieldType => genReadValue(at.unwrap, protoName)
      case TBool => v(s"$protoName.readBool()")
      case TByte => v(s"$protoName.readByte()")
      case TI16 => v(s"$protoName.readI16()")
      case TI32 => v(s"$protoName.readI32()")
      case TI64 => v(s"$protoName.readI64()")
      case TDouble => v(s"$protoName.readDouble()")
      case TString => v(s"$protoName.readString()")
      case TBinary => v(s"$protoName.readBinary()")
      case _: StructType => genType(fieldType).append(s".decode($protoName)")
      case _: EnumType => genType(fieldType).append(s".getOrUnknown($protoName.readI32())")
      case t: SetType =>
        val readElement = genReadValueFn1(t.eltType)
        v(s"$rootProtos.readSet($protoName, $readElement)")
      case t: ListType =>
        val readElement = genReadValueFn1(t.eltType)
        v(s"$rootProtos.readList($protoName, $readElement)")
      case t: MapType =>
        val readKey = genReadValueFn1(t.keyType)
        val readVal = genReadValueFn1(t.valueType)
        v(s"$rootProtos.readMap($protoName, $readKey, $readVal)")
      case _ => throw new IllegalArgumentException(s"Unsupported FieldType: $fieldType")
    }
  }