// <auto-generated>
/*
 * OpenAPI Petstore
 *
 * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
 *
 * The version of the OpenAPI document: 1.0.0
 * Generated by: https://github.com/openapitools/openapi-generator.git
 */

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations;
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
using Org.OpenAPITools.Client;

namespace Org.OpenAPITools.Model
{
    /// <summary>
    /// Defines EnumArrays_just_symbol
    /// </summary>
    public enum EnumArraysJustSymbol
    {
        /// <summary>
        /// Enum GreaterThanOrEqualTo for value: &gt;&#x3D;
        /// </summary>
        GreaterThanOrEqualTo = 1,

        /// <summary>
        /// Enum Dollar for value: $
        /// </summary>
        Dollar = 2
    }

    /// <summary>
    /// Converts <see cref="EnumArraysJustSymbol"/> to and from the JSON value
    /// </summary>
    public static class EnumArraysJustSymbolValueConverter
    {
        /// <summary>
        /// Parses a given value to <see cref="EnumArraysJustSymbol"/>
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static EnumArraysJustSymbol FromString(string value)
        {
            if (value.Equals(">="))
                return EnumArraysJustSymbol.GreaterThanOrEqualTo;

            if (value.Equals("$"))
                return EnumArraysJustSymbol.Dollar;

            throw new NotImplementedException($"Could not convert value to type EnumArraysJustSymbol: '{value}'");
        }

        /// <summary>
        /// Parses a given value to <see cref="EnumArraysJustSymbol"/>
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static EnumArraysJustSymbol? FromStringOrDefault(string value)
        {
            if (value.Equals(">="))
                return EnumArraysJustSymbol.GreaterThanOrEqualTo;

            if (value.Equals("$"))
                return EnumArraysJustSymbol.Dollar;

            return null;
        }

        /// <summary>
        /// Converts the <see cref="EnumArraysJustSymbol"/> to the json value
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public static string ToJsonValue(EnumArraysJustSymbol value)
        {
            if (value == EnumArraysJustSymbol.GreaterThanOrEqualTo)
                return ">=";

            if (value == EnumArraysJustSymbol.Dollar)
                return "$";

            throw new NotImplementedException($"Value could not be handled: '{value}'");
        }
    }

    /// <summary>
    /// A Json converter for type <see cref="EnumArraysJustSymbol"/>
    /// </summary>
    /// <exception cref="NotImplementedException"></exception>
    public class EnumArraysJustSymbolJsonConverter : JsonConverter<EnumArraysJustSymbol>
    {
        /// <summary>
        /// Returns a  from the Json object
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="typeToConvert"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public override EnumArraysJustSymbol Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            string rawValue = reader.GetString();

            EnumArraysJustSymbol? result = rawValue == null
                ? null
                : EnumArraysJustSymbolValueConverter.FromStringOrDefault(rawValue);

            if (result != null)
                return result.Value;

            throw new JsonException();
        }

        /// <summary>
        /// Writes the EnumArraysJustSymbol to the json writer
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="enumArraysJustSymbol"></param>
        /// <param name="options"></param>
        public override void Write(Utf8JsonWriter writer, EnumArraysJustSymbol enumArraysJustSymbol, JsonSerializerOptions options)
        {
            writer.WriteStringValue(enumArraysJustSymbol.ToString());
        }
    }

    /// <summary>
    /// A Json converter for type <see cref="EnumArraysJustSymbol"/>
    /// </summary>
    public class EnumArraysJustSymbolNullableJsonConverter : JsonConverter<EnumArraysJustSymbol?>
    {
        /// <summary>
        /// Returns a EnumArraysJustSymbol from the Json object
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="typeToConvert"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public override EnumArraysJustSymbol? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            string rawValue = reader.GetString();

            EnumArraysJustSymbol? result = rawValue == null
                ? null
                : EnumArraysJustSymbolValueConverter.FromStringOrDefault(rawValue);

            if (result != null)
                return result.Value;

            throw new JsonException();
        }

        /// <summary>
        /// Writes the DateTime to the json writer
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="enumArraysJustSymbol"></param>
        /// <param name="options"></param>
        public override void Write(Utf8JsonWriter writer, EnumArraysJustSymbol? enumArraysJustSymbol, JsonSerializerOptions options)
        {
            writer.WriteStringValue(enumArraysJustSymbol?.ToString() ?? "null");
        }
    }
}
