using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class FilterConditionTypeInfo
{
	public static FilterConditionTypeEnum ValueToFilterConditionType(uint value)
	{
		switch (value)
		{
		case 0u:
			return FilterConditionTypeEnum.All_Devices;
		case 1u:
			return FilterConditionTypeEnum.Device_with_specific_Class_of_Device;
		case 2u:
			return FilterConditionTypeEnum.Device_with_specific_BD_ADDR;
		default:
			if (value >= 3 && value <= 255)
			{
				return FilterConditionTypeEnum.RESERVED;
			}
			return FilterConditionTypeEnum.InvalidFilterConditionTypeValue;
		}
	}

	public static uint FilterConditionTypeToValue(FilterConditionTypeEnum enumItem)
	{
		return enumItem switch
		{
			FilterConditionTypeEnum.All_Devices => 0u, 
			FilterConditionTypeEnum.Device_with_specific_Class_of_Device => 1u, 
			FilterConditionTypeEnum.Device_with_specific_BD_ADDR => 2u, 
			FilterConditionTypeEnum.RESERVED => 3u, 
			_ => uint.MaxValue, 
		};
	}

	public static string FilterConditionTypeToString(FilterConditionTypeEnum enumItem)
	{
		return enumItem switch
		{
			FilterConditionTypeEnum.All_Devices => "All_Devices", 
			FilterConditionTypeEnum.Device_with_specific_Class_of_Device => "Device_with_specific_Class_of_Device", 
			FilterConditionTypeEnum.Device_with_specific_BD_ADDR => "Device_with_specific_BD_ADDR", 
			FilterConditionTypeEnum.RESERVED => "Reserved", 
			_ => "Invalid FilterConditionType Value", 
		};
	}

	public static string FilterConditionTypeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = All_Devices");
		stringBuilder.AppendLine("0x1 = Device_with_specific_Class_of_Device");
		stringBuilder.AppendLine("0x2 = Device_with_specific_BD_ADDR");
		stringBuilder.AppendLine("0x3-0xFF = Reserved");
		return stringBuilder.ToString();
	}
}
