// Code generated by github.com/actgardner/gogen-avro/v10. DO NOT EDIT.
/*
 * SOURCE:
 *     superhero.avsc
 */
package models

import (
	"io"

	"github.com/actgardner/gogen-avro/v10/vm"
	"github.com/actgardner/gogen-avro/v10/vm/types"
)

func writeArraySuperpower(r []Superpower, w io.Writer) error {
	err := vm.WriteLong(int64(len(r)), w)
	if err != nil || len(r) == 0 {
		return err
	}
	for _, e := range r {
		err = writeSuperpower(e, w)
		if err != nil {
			return err
		}
	}
	return vm.WriteLong(0, w)
}

type ArraySuperpowerWrapper struct {
	Target *[]Superpower
}

func (_ ArraySuperpowerWrapper) SetBoolean(v bool)                { panic("Unsupported operation") }
func (_ ArraySuperpowerWrapper) SetInt(v int32)                   { panic("Unsupported operation") }
func (_ ArraySuperpowerWrapper) SetLong(v int64)                  { panic("Unsupported operation") }
func (_ ArraySuperpowerWrapper) SetFloat(v float32)               { panic("Unsupported operation") }
func (_ ArraySuperpowerWrapper) SetDouble(v float64)              { panic("Unsupported operation") }
func (_ ArraySuperpowerWrapper) SetBytes(v []byte)                { panic("Unsupported operation") }
func (_ ArraySuperpowerWrapper) SetString(v string)               { panic("Unsupported operation") }
func (_ ArraySuperpowerWrapper) SetUnionElem(v int64)             { panic("Unsupported operation") }
func (_ ArraySuperpowerWrapper) Get(i int) types.Field            { panic("Unsupported operation") }
func (_ ArraySuperpowerWrapper) AppendMap(key string) types.Field { panic("Unsupported operation") }
func (_ ArraySuperpowerWrapper) Finalize()                        {}
func (_ ArraySuperpowerWrapper) SetDefault(i int)                 { panic("Unsupported operation") }
func (r ArraySuperpowerWrapper) HintSize(s int) {
	if len(*r.Target) == 0 {
		*r.Target = make([]Superpower, 0, s)
	}
}
func (r ArraySuperpowerWrapper) NullField(i int) {
	panic("Unsupported operation")
}

func (r ArraySuperpowerWrapper) AppendArray() types.Field {
	var v Superpower
	v = NewSuperpower()

	*r.Target = append(*r.Target, v)
	return &types.Record{Target: &(*r.Target)[len(*r.Target)-1]}
}
