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

/// Artikel. ERP-Mirror; die `article_number` ist die business-stabile Artikelnummer aus dem ERP-Stamm und dient gleichzeitig als Brücke.  `scannable = false` markiert nicht-physische Positionen wie Dienstleistungen, Versandpauschalen o.ä. — sie tauchen zwar als `DeliveryItem` auf, blockieren aber den Beladen-Fortschritt nicht.
///
/// Properties:
/// * [articleNumber] 
/// * [defaultWarehouseId] 
/// * [id] 
/// * [name] 
/// * [scannable] 
@BuiltValue()
abstract class Article implements Built<Article, ArticleBuilder> {
  @BuiltValueField(wireName: r'articleNumber')
  String get articleNumber;

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

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

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

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

  Article._();

  factory Article([void updates(ArticleBuilder b)]) = _$Article;

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

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

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

  @override
  final String wireName = r'Article';

  Iterable<Object?> _serializeProperties(
    Serializers serializers,
    Article object, {
    FullType specifiedType = FullType.unspecified,
  }) sync* {
    yield r'articleNumber';
    yield serializers.serialize(
      object.articleNumber,
      specifiedType: const FullType(String),
    );
    if (object.defaultWarehouseId != null) {
      yield r'defaultWarehouseId';
      yield serializers.serialize(
        object.defaultWarehouseId,
        specifiedType: const FullType.nullable(String),
      );
    }
    yield r'id';
    yield serializers.serialize(
      object.id,
      specifiedType: const FullType(String),
    );
    yield r'name';
    yield serializers.serialize(
      object.name,
      specifiedType: const FullType(String),
    );
    yield r'scannable';
    yield serializers.serialize(
      object.scannable,
      specifiedType: const FullType(bool),
    );
  }

  @override
  Object serialize(
    Serializers serializers,
    Article 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 ArticleBuilder 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'articleNumber':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.articleNumber = valueDes;
          break;
        case r'defaultWarehouseId':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType.nullable(String),
          ) as String?;
          if (valueDes == null) continue;
          result.defaultWarehouseId = valueDes;
          break;
        case r'id':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.id = valueDes;
          break;
        case r'name':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(String),
          ) as String;
          result.name = valueDes;
          break;
        case r'scannable':
          final valueDes = serializers.deserialize(
            value,
            specifiedType: const FullType(bool),
          ) as bool;
          result.scannable = valueDes;
          break;
        default:
          unhandled.add(key);
          unhandled.add(value);
          break;
      }
    }
  }

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

