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

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

part 'cars_list.g.dart';

/// CarsList
///
/// Properties:
/// * [cars] 
@BuiltValue()
abstract class CarsList implements Built<CarsList, CarsListBuilder> {
  @BuiltValueField(wireName: r'cars')
  BuiltList<Car> get cars;

  CarsList._();

  factory CarsList([void updates(CarsListBuilder b)]) = _$CarsList;

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

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

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

  @override
  final String wireName = r'CarsList';

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

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

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

