//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//

// ignore_for_file: unused_element
import 'package:holzleitner_api/src/model/service_kind.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'create_service_request.g.dart';

/// CreateServiceRequest
///
/// Properties:
/// * [key] - Eindeutiger Programm-Identifier (z. B. `\"podium_setup\"`).
/// * [kind] 
/// * [maxValue] 
/// * [minValue] - Nur bei `Numeric` sinnvoll.
/// * [name] 
/// * [sortOrder] 
@BuiltValue()
abstract class CreateServiceRequest implements Built<CreateServiceRequest, CreateServiceRequestBuilder> {
  /// Eindeutiger Programm-Identifier (z. B. `\"podium_setup\"`).
  @BuiltValueField(wireName: r'key')
  String get key;

  @BuiltValueField(wireName: r'kind')
  ServiceKind get kind;
  // enum kindEnum {  boolean,  numeric,  };

  @BuiltValueField(wireName: r'maxValue')
  int? get maxValue;

  /// Nur bei `Numeric` sinnvoll.
  @BuiltValueField(wireName: r'minValue')
  int? get minValue;

  @BuiltValueField(wireName: r'name')
  String get name;

  @BuiltValueField(wireName: r'sortOrder')
  int? get sortOrder;

  CreateServiceRequest._();

  factory CreateServiceRequest([void updates(CreateServiceRequestBuilder b)]) = _$CreateServiceRequest;

  @BuiltValueHook(initializeBuilder: true)
  static void _defaults(CreateServiceRequestBuilder b) => b;

  @BuiltValueSerializer(custom: true)
  static Serializer<CreateServiceRequest> get serializer => _$CreateServiceRequestSerializer();
}

class _$CreateServiceRequestSerializer implements PrimitiveSerializer<CreateServiceRequest> {
  @override
  final Iterable<Type> types = const [CreateServiceRequest, _$CreateServiceRequest];

  @override
  final String wireName = r'CreateServiceRequest';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    CreateServiceRequest object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    yield r'key';
    yield serializers.serialize(
      object.key,
      specifiedType: const FullType(String),
    );
    yield r'kind';
    yield serializers.serialize(
      object.kind,
      specifiedType: const FullType(ServiceKind),
    );
    if (object.maxValue != null) {
      yield r'maxValue';
      yield serializers.serialize(
        object.maxValue,
        specifiedType: const FullType.nullable(int),
      );
    }
    if (object.minValue != null) {
      yield r'minValue';
      yield serializers.serialize(
        object.minValue,
        specifiedType: const FullType.nullable(int),
      );
    }
    yield r'name';
    yield serializers.serialize(
      object.name,
      specifiedType: const FullType(String),
    );
    if (object.sortOrder != null) {
      yield r'sortOrder';
      yield serializers.serialize(
        object.sortOrder,
        specifiedType: const FullType.nullable(int),
      );
    }
  }

  @override
  Object serialize(
    Serializers serializers,
    CreateServiceRequest object, {
    FullType specifiedType = FullType.unspecified,
  }) {
    return _serializeProperties(serializers, object, specifiedType: specifiedType).toList();
  }

  void _deserializeProperties(
    Serializers serializers,
    Object serialized, {
    FullType specifiedType = FullType.unspecified,
    required List<Object?> serializedList,
    required CreateServiceRequestBuilder result,
    required List<Object?> unhandled,
  }) {
    for (var i = 0; i < serializedList.length; i += 2) {
      final key = serializedList[i] as String;
      final value = serializedList[i + 1];
      switch (key) {
        case r'key':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.key = valueDes;
          break;
        case r'kind':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(ServiceKind),
          ) as ServiceKind;
          result.kind = valueDes;
          break;
        case r'maxValue':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(int),
          ) as int?;
          if (valueDes == null) continue;
          result.maxValue = valueDes;
          break;
        case r'minValue':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(int),
          ) as int?;
          if (valueDes == null) continue;
          result.minValue = valueDes;
          break;
        case r'name':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.name = valueDes;
          break;
        case r'sortOrder':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(int),
          ) as int?;
          if (valueDes == null) continue;
          result.sortOrder = valueDes;
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

  @override
  CreateServiceRequest deserialize(
    Serializers serializers,
    Object serialized, {
    FullType specifiedType = FullType.unspecified,
  }) {
    final result = CreateServiceRequestBuilder();
    final serializedList = (serialized as Iterable<Object?>).toList();
    final unhandled = <Object?>[];
    _deserializeProperties(
      serializers,
      serialized,
      specifiedType: specifiedType,
      serializedList: serializedList,
      unhandled: unhandled,
      result: result,
    );
    return result.build();
  }
}

