package ks.empty;

import java.lang.*;
import java.util.*;
import java.nio.*;
import java.nio.charset.Charset;

import ks.*;

public class Empty
{
	public static class Parent extends KSObject
	{
		public Integer count;
		

		public Parent()
		{
		}
		
		public static final String NameStatic = "Parent";
		
		@Override
		public String Name() { return "Parent"; }
		
		@Override
		public byte[] serialize()
		{
			List<Byte> s = new ArrayList<>();
			
			// serialize count
			s.add((byte) ((count == null) ? 0 : 1));
			if (count != null)
			{
				s.addAll(b2B(ByteBuffer.allocate(Integer.BYTES).order(ByteOrder.LITTLE_ENDIAN).putInt(count).array()));
			}
			
			return B2b(s);
		}
		
		@Override
		protected int deserialize(byte[] s, int offset)
		{
			// deserialize count
			byte tmp0;
			tmp0 = s[offset];
			offset += Byte.BYTES;
			if (tmp0 == 1)
			{
				count = ByteBuffer.wrap(Arrays.copyOfRange(s, offset, offset + Integer.BYTES)).order(ByteOrder.LITTLE_ENDIAN).getInt();
				offset += Integer.BYTES;
			}
			else
				count = null;
			
			return offset;
		}
	}
	
	public static class Child extends Parent
	{
		

		public Child()
		{
		}
		
		public static final String NameStatic = "Child";
		
		@Override
		public String Name() { return "Child"; }
		
		@Override
		public byte[] serialize()
		{
			List<Byte> s = new ArrayList<>();
			
			// serialize parents
			s.addAll(b2B(super.serialize()));
			
			return B2b(s);
		}
		
		@Override
		protected int deserialize(byte[] s, int offset)
		{
			// deserialize parents
			offset = super.deserialize(s, offset);
			
			return offset;
		}
	}
} // Empty
