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

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

part 'apply_scans_request.g.dart';

/// ApplyScansRequest
///
/// Properties:
/// * [scans] 
@BuiltValue()
abstract class ApplyScansRequest implements Built<ApplyScansRequest, ApplyScansRequestBuilder> {
  @BuiltValueField(wireName: r'scans')
  BuiltList<ScanEvent> get scans;

  ApplyScansRequest._();

  factory ApplyScansRequest([void updates(ApplyScansRequestBuilder b)]) = _$ApplyScansRequest;

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

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

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

  @override
  final String wireName = r'ApplyScansRequest';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    ApplyScansRequest object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    yield r'scans';
    yield serializers.serialize(
      object.scans,
      specifiedType: const FullType(BuiltList, [FullType(ScanEvent)]),
    );
  }

  @override
  Object serialize(
    Serializers serializers,
    ApplyScansRequest 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 ApplyScansRequestBuilder 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'scans':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(BuiltList, [FullType(ScanEvent)]),
          ) as BuiltList<ScanEvent>;
          result.scans.replace(valueDes);
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

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

