override def toAvroDefault()

in elitzur-avro/src/main/scala/com/spotify/elitzur/converters/avro/AvroConverter.scala [225:242]


  override def toAvroDefault(v: C[T], defaultGenericContainer: GenericContainer): Any = {
    val c = implicitly[AvroConverter[T]]
    val output: java.util.List[Any] = new java.util.ArrayList[Any]
    // We use the first record in the default list as the default - otherwise length might not match
    val firstDefault = defaultGenericContainer.asInstanceOf[GenericArray[_]].get(0)
    val isNestedRecord = AvroElitzurConversionUtils
      .isAvroRecordType(defaultGenericContainer.getSchema.getElementType)
    if (isNestedRecord) {
      toSeq(v).iterator.foreach(i => {
        output.add(c.toAvroDefault(i, firstDefault.asInstanceOf[GenericRecord]))
      })
    } else {
      toSeq(v).iterator.foreach(i => {
        output.add(c.toAvroDefault(i, defaultGenericContainer))
      })
    }
    output
  }