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

/// Pro-Lieferung gewählter Wert eines Service. Genau einer der beiden Wert-Slots ist je nach `ServiceKind` gesetzt; per `service_id`/`delivery_id` clientseitig join-bar (wie Notizen/Gutschriften).
///
/// Properties:
/// * [boolValue] 
/// * [deliveryId] 
/// * [numericValue] 
/// * [serviceId] 
@BuiltValue()
abstract class DeliveryServiceValue implements Built<DeliveryServiceValue, DeliveryServiceValueBuilder> {
  @BuiltValueField(wireName: r'boolValue')
  bool? get boolValue;

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

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

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

  DeliveryServiceValue._();

  factory DeliveryServiceValue([void updates(DeliveryServiceValueBuilder b)]) = _$DeliveryServiceValue;

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

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

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

  @override
  final String wireName = r'DeliveryServiceValue';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    DeliveryServiceValue object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    if (object.boolValue != null) {
      yield r'boolValue';
      yield serializers.serialize(
        object.boolValue,
        specifiedType: const FullType.nullable(bool),
      );
    }
    yield r'deliveryId';
    yield serializers.serialize(
      object.deliveryId,
      specifiedType: const FullType(String),
    );
    if (object.numericValue != null) {
      yield r'numericValue';
      yield serializers.serialize(
        object.numericValue,
        specifiedType: const FullType.nullable(int),
      );
    }
    yield r'serviceId';
    yield serializers.serialize(
      object.serviceId,
      specifiedType: const FullType(String),
    );
  }

  @override
  Object serialize(
    Serializers serializers,
    DeliveryServiceValue 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 DeliveryServiceValueBuilder 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'boolValue':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(bool),
          ) as bool?;
          if (valueDes == null) continue;
          result.boolValue = valueDes;
          break;
        case r'deliveryId':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.deliveryId = valueDes;
          break;
        case r'numericValue':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(int),
          ) as int?;
          if (valueDes == null) continue;
          result.numericValue = valueDes;
          break;
        case r'serviceId':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.serviceId = valueDes;
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

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

