// ------------------------------------------------------------------------------
// <auto-generated>
//    Generated by avrogen, version 1.7.7.5
//    Changes to this file may cause incorrect behavior and will be lost if code
//    is regenerated
// </auto-generated>
// ------------------------------------------------------------------------------

using System;
using Confluent.SchemaRegistry;

namespace Orleans.Streams.Kafka.E2E.Grains
{
	using global::Avro;
	using global::Avro.Specific;

	[GenerateSerializer]
	public partial class TestModelAvro : ISpecificRecord
	{
		private static Random Rand = new Random();

		public static Schema _SCHEMA = Schema.Parse("{\"type\":\"record\",\"name\":\"TestModelAvro\",\"namespace\":\"Orleans.Streams.Kafka.E2E.Gr" +
				"ains\",\"fields\":[{\"name\":\"numberOfLegs\",\"type\":\"int\"},{\"name\":\"numberOfHeads\",\"ty" +
				"pe\":\"int\"},{\"name\":\"isLastMessage\",\"type\":\"boolean\"}]}");
		private int _numberOfLegs;
		private int _numberOfHeads;
		private bool _isLastMessage;
		public virtual Schema Schema
		{
			get
			{
				return TestModelAvro._SCHEMA;
			}
		}
		
		[Id(0)]
		public int numberOfLegs
		{
			get
			{
				return this._numberOfLegs;
			}
			set
			{
				this._numberOfLegs = value;
			}
		}
		
		[Id(1)]
		public int numberOfHeads
		{
			get
			{
				return this._numberOfHeads;
			}
			set
			{
				this._numberOfHeads = value;
			}
		}
		
		[Id(2)]
		public bool isLastMessage
		{
			get
			{
				return this._isLastMessage;
			}
			set
			{
				this._isLastMessage = value;
			}
		}
		public virtual object Get(int fieldPos)
		{
			switch (fieldPos)
			{
				case 0: return this.numberOfLegs;
				case 1: return this.numberOfHeads;
				case 2: return this.isLastMessage;
				default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Get()");
			};
		}
		public virtual void Put(int fieldPos, object fieldValue)
		{
			switch (fieldPos)
			{
				case 0: this.numberOfLegs = (System.Int32)fieldValue; break;
				case 1: this.numberOfHeads = (System.Int32)fieldValue; break;
				case 2: this.isLastMessage = (System.Boolean)fieldValue; break;
				default: throw new AvroRuntimeException("Bad index " + fieldPos + " in Put()");
			};
		}

		public override bool Equals(object obj)
		{
			var mod = (TestModelAvro)obj;
			return mod.numberOfHeads == numberOfHeads && mod.numberOfLegs == numberOfLegs;
		}

		public static TestModelAvro Random()
			=> new TestModelAvro
			{
				numberOfHeads = Rand.Next(1000),
				numberOfLegs = Rand.Next(1000)
			};
	}
}
