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

// ignore_for_file: unused_element
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'car.g.dart';

/// Fahrzeug eines [`crate::domain::Account`]. Wird in der App selbst gepflegt — kein ERP-Spiegel. Eindeutig per UUID.  Im Audit-Log ist der `Car` der „Akteur\": die Personalnummer-Ebene (Account) ist gröber und unterscheidet nicht zwischen mehreren gleichzeitig aktiven Fahrern desselben Subunternehmens.
///
/// Properties:
/// * [accountId] - Verweis auf [`crate::domain::Account::personalnummer`].
/// * [active] 
/// * [id] 
/// * [plate] 
@BuiltValue()
abstract class Car implements Built<Car, CarBuilder> {
  /// Verweis auf [`crate::domain::Account::personalnummer`].
  @BuiltValueField(wireName: r'accountId')
  int get accountId;

  @BuiltValueField(wireName: r'active')
  bool get active;

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

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

  Car._();

  factory Car([void updates(CarBuilder b)]) = _$Car;

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

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

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

  @override
  final String wireName = r'Car';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    Car object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    yield r'accountId';
    yield serializers.serialize(
      object.accountId,
      specifiedType: const FullType(int),
    );
    yield r'active';
    yield serializers.serialize(
      object.active,
      specifiedType: const FullType(bool),
    );
    yield r'id';
    yield serializers.serialize(
      object.id,
      specifiedType: const FullType(String),
    );
    yield r'plate';
    yield serializers.serialize(
      object.plate,
      specifiedType: const FullType(String),
    );
  }

  @override
  Object serialize(
    Serializers serializers,
    Car 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 CarBuilder 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'accountId':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(int),
          ) as int;
          result.accountId = valueDes;
          break;
        case r'active':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(bool),
          ) as bool;
          result.active = valueDes;
          break;
        case r'id':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.id = valueDes;
          break;
        case r'plate':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.plate = valueDes;
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

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

