//
// 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 'delivery_note.g.dart';

/// Notiz an einer Lieferung — frei eingegeben durch den Fahrer.  Mindestens eines von `text` oder `image_attachment` muss gesetzt sein. Die Constraint sitzt sowohl im DB-Schema (CHECK) als auch in der Application-Schicht.
///
/// Properties:
/// * [authorCarId] - Fahrzeug, falls bekannt — nullable bis das Backend Cars verwaltet.
/// * [authorPersonalnummer] - Personalnummer des Akteurs (aus dem JWT). Pflicht.
/// * [createdAt] 
/// * [deliveryId] 
/// * [id] 
/// * [imageAttachment] - Referenz auf einen Bild-Anhang (z. B. Object-Storage-Key/URL).
/// * [text] 
@BuiltValue()
abstract class DeliveryNote implements Built<DeliveryNote, DeliveryNoteBuilder> {
  /// Fahrzeug, falls bekannt — nullable bis das Backend Cars verwaltet.
  @BuiltValueField(wireName: r'authorCarId')
  String? get authorCarId;

  /// Personalnummer des Akteurs (aus dem JWT). Pflicht.
  @BuiltValueField(wireName: r'authorPersonalnummer')
  int get authorPersonalnummer;

  @BuiltValueField(wireName: r'createdAt')
  DateTime get createdAt;

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

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

  /// Referenz auf einen Bild-Anhang (z. B. Object-Storage-Key/URL).
  @BuiltValueField(wireName: r'imageAttachment')
  String? get imageAttachment;

  @BuiltValueField(wireName: r'text')
  String? get text;

  DeliveryNote._();

  factory DeliveryNote([void updates(DeliveryNoteBuilder b)]) = _$DeliveryNote;

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

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

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

  @override
  final String wireName = r'DeliveryNote';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    DeliveryNote object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    if (object.authorCarId != null) {
      yield r'authorCarId';
      yield serializers.serialize(
        object.authorCarId,
        specifiedType: const FullType.nullable(String),
      );
    }
    yield r'authorPersonalnummer';
    yield serializers.serialize(
      object.authorPersonalnummer,
      specifiedType: const FullType(int),
    );
    yield r'createdAt';
    yield serializers.serialize(
      object.createdAt,
      specifiedType: const FullType(DateTime),
    );
    yield r'deliveryId';
    yield serializers.serialize(
      object.deliveryId,
      specifiedType: const FullType(String),
    );
    yield r'id';
    yield serializers.serialize(
      object.id,
      specifiedType: const FullType(String),
    );
    if (object.imageAttachment != null) {
      yield r'imageAttachment';
      yield serializers.serialize(
        object.imageAttachment,
        specifiedType: const FullType.nullable(String),
      );
    }
    if (object.text != null) {
      yield r'text';
      yield serializers.serialize(
        object.text,
        specifiedType: const FullType.nullable(String),
      );
    }
  }

  @override
  Object serialize(
    Serializers serializers,
    DeliveryNote 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 DeliveryNoteBuilder 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'authorCarId':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.authorCarId = valueDes;
          break;
        case r'authorPersonalnummer':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(int),
          ) as int;
          result.authorPersonalnummer = valueDes;
          break;
        case r'createdAt':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(DateTime),
          ) as DateTime;
          result.createdAt = valueDes;
          break;
        case r'deliveryId':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.deliveryId = valueDes;
          break;
        case r'id':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.id = valueDes;
          break;
        case r'imageAttachment':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.imageAttachment = valueDes;
          break;
        case r'text':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.text = valueDes;
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

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

