// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'material.dart';

// **************************************************************************
// _IsarCollectionGenerator
// **************************************************************************

// coverage:ignore-file
// ignore_for_file: duplicate_ignore, invalid_use_of_protected_member, lines_longer_than_80_chars, constant_identifier_names, avoid_js_rounded_ints, no_leading_underscores_for_local_identifiers, require_trailing_commas, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_in_if_null_operators, library_private_types_in_public_api, prefer_const_constructors
// ignore_for_file: type=lint

extension GetMaterialCollection on Isar {
  IsarCollection<int, Material> get materials => this.collection();
}

const MaterialSchema = IsarGeneratedSchema(
  schema: IsarSchema(
    name: 'Material',
    idName: 'id',
    embedded: false,
    properties: [
      IsarPropertySchema(
        name: 'name',
        type: IsarType.string,
      ),
      IsarPropertySchema(
        name: 'sourceOfSupply',
        type: IsarType.objectList,
        target: 'IdValueColor',
      ),
      IsarPropertySchema(
        name: 'averagePrice',
        type: IsarType.double,
      ),
    ],
    indexes: [
      IsarIndexSchema(
        name: 'name',
        properties: [
          "name",
        ],
        unique: true,
        hash: true,
      ),
    ],
  ),
  converter: IsarObjectConverter<int, Material>(
    serialize: serializeMaterial,
    deserialize: deserializeMaterial,
    deserializeProperty: deserializeMaterialProp,
  ),
  embeddedSchemas: [IdValueColorSchema],
);

@isarProtected
int serializeMaterial(IsarWriter writer, Material object) {
  {
    final value = object.name;
    if (value == null) {
      IsarCore.writeNull(writer, 1);
    } else {
      IsarCore.writeString(writer, 1, value);
    }
  }
  {
    final list = object.sourceOfSupply;
    if (list == null) {
      IsarCore.writeNull(writer, 2);
    } else {
      final listWriter = IsarCore.beginList(writer, 2, list.length);
      for (var i = 0; i < list.length; i++) {
        {
          final value = list[i];
          final objectWriter = IsarCore.beginObject(listWriter, i);
          serializeIdValueColor(objectWriter, value);
          IsarCore.endObject(listWriter, objectWriter);
        }
      }
      IsarCore.endList(writer, listWriter);
    }
  }
  IsarCore.writeDouble(writer, 3, object.averagePrice ?? double.nan);
  return object.id;
}

@isarProtected
Material deserializeMaterial(IsarReader reader) {
  final object = Material();
  object.name = IsarCore.readString(reader, 1);
  {
    final length = IsarCore.readList(reader, 2, IsarCore.readerPtrPtr);
    {
      final reader = IsarCore.readerPtr;
      if (reader.isNull) {
        object.sourceOfSupply = null;
      } else {
        final list =
            List<IdValueColor>.filled(length, IdValueColor(), growable: true);
        for (var i = 0; i < length; i++) {
          {
            final objectReader = IsarCore.readObject(reader, i);
            if (objectReader.isNull) {
              list[i] = IdValueColor();
            } else {
              final embedded = deserializeIdValueColor(objectReader);
              IsarCore.freeReader(objectReader);
              list[i] = embedded;
            }
          }
        }
        IsarCore.freeReader(reader);
        object.sourceOfSupply = list;
      }
    }
  }
  {
    final value = IsarCore.readDouble(reader, 3);
    if (value.isNaN) {
      object.averagePrice = null;
    } else {
      object.averagePrice = value;
    }
  }
  object.id = IsarCore.readId(reader);
  return object;
}

@isarProtected
dynamic deserializeMaterialProp(IsarReader reader, int property) {
  switch (property) {
    case 1:
      return IsarCore.readString(reader, 1);
    case 2:
      {
        final length = IsarCore.readList(reader, 2, IsarCore.readerPtrPtr);
        {
          final reader = IsarCore.readerPtr;
          if (reader.isNull) {
            return null;
          } else {
            final list = List<IdValueColor>.filled(length, IdValueColor(),
                growable: true);
            for (var i = 0; i < length; i++) {
              {
                final objectReader = IsarCore.readObject(reader, i);
                if (objectReader.isNull) {
                  list[i] = IdValueColor();
                } else {
                  final embedded = deserializeIdValueColor(objectReader);
                  IsarCore.freeReader(objectReader);
                  list[i] = embedded;
                }
              }
            }
            IsarCore.freeReader(reader);
            return list;
          }
        }
      }
    case 3:
      {
        final value = IsarCore.readDouble(reader, 3);
        if (value.isNaN) {
          return null;
        } else {
          return value;
        }
      }
    case 0:
      return IsarCore.readId(reader);
    default:
      throw ArgumentError('Unknown property: $property');
  }
}

sealed class _MaterialUpdate {
  bool call({
    required int id,
    String? name,
    double? averagePrice,
  });
}

class _MaterialUpdateImpl implements _MaterialUpdate {
  const _MaterialUpdateImpl(this.collection);

  final IsarCollection<int, Material> collection;

  @override
  bool call({
    required int id,
    Object? name = ignore,
    Object? averagePrice = ignore,
  }) {
    return collection.updateProperties([
          id
        ], {
          if (name != ignore) 1: name as String?,
          if (averagePrice != ignore) 3: averagePrice as double?,
        }) >
        0;
  }
}

sealed class _MaterialUpdateAll {
  int call({
    required List<int> id,
    String? name,
    double? averagePrice,
  });
}

class _MaterialUpdateAllImpl implements _MaterialUpdateAll {
  const _MaterialUpdateAllImpl(this.collection);

  final IsarCollection<int, Material> collection;

  @override
  int call({
    required List<int> id,
    Object? name = ignore,
    Object? averagePrice = ignore,
  }) {
    return collection.updateProperties(id, {
      if (name != ignore) 1: name as String?,
      if (averagePrice != ignore) 3: averagePrice as double?,
    });
  }
}

extension MaterialUpdate on IsarCollection<int, Material> {
  _MaterialUpdate get update => _MaterialUpdateImpl(this);

  _MaterialUpdateAll get updateAll => _MaterialUpdateAllImpl(this);
}

sealed class _MaterialQueryUpdate {
  int call({
    String? name,
    double? averagePrice,
  });
}

class _MaterialQueryUpdateImpl implements _MaterialQueryUpdate {
  const _MaterialQueryUpdateImpl(this.query, {this.limit});

  final IsarQuery<Material> query;
  final int? limit;

  @override
  int call({
    Object? name = ignore,
    Object? averagePrice = ignore,
  }) {
    return query.updateProperties(limit: limit, {
      if (name != ignore) 1: name as String?,
      if (averagePrice != ignore) 3: averagePrice as double?,
    });
  }
}

extension MaterialQueryUpdate on IsarQuery<Material> {
  _MaterialQueryUpdate get updateFirst =>
      _MaterialQueryUpdateImpl(this, limit: 1);

  _MaterialQueryUpdate get updateAll => _MaterialQueryUpdateImpl(this);
}

class _MaterialQueryBuilderUpdateImpl implements _MaterialQueryUpdate {
  const _MaterialQueryBuilderUpdateImpl(this.query, {this.limit});

  final QueryBuilder<Material, Material, QOperations> query;
  final int? limit;

  @override
  int call({
    Object? name = ignore,
    Object? averagePrice = ignore,
  }) {
    final q = query.build();
    try {
      return q.updateProperties(limit: limit, {
        if (name != ignore) 1: name as String?,
        if (averagePrice != ignore) 3: averagePrice as double?,
      });
    } finally {
      q.close();
    }
  }
}

extension MaterialQueryBuilderUpdate
    on QueryBuilder<Material, Material, QOperations> {
  _MaterialQueryUpdate get updateFirst =>
      _MaterialQueryBuilderUpdateImpl(this, limit: 1);

  _MaterialQueryUpdate get updateAll => _MaterialQueryBuilderUpdateImpl(this);
}

extension MaterialQueryFilter
    on QueryBuilder<Material, Material, QFilterCondition> {
  QueryBuilder<Material, Material, QAfterFilterCondition> nameIsNull() {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(const IsNullCondition(property: 1));
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameIsNotNull() {
    return QueryBuilder.apply(not(), (query) {
      return query.addFilterCondition(const IsNullCondition(property: 1));
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameEqualTo(
    String? value, {
    bool caseSensitive = true,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        EqualCondition(
          property: 1,
          value: value,
          caseSensitive: caseSensitive,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameGreaterThan(
    String? value, {
    bool caseSensitive = true,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        GreaterCondition(
          property: 1,
          value: value,
          caseSensitive: caseSensitive,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition>
      nameGreaterThanOrEqualTo(
    String? value, {
    bool caseSensitive = true,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        GreaterOrEqualCondition(
          property: 1,
          value: value,
          caseSensitive: caseSensitive,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameLessThan(
    String? value, {
    bool caseSensitive = true,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        LessCondition(
          property: 1,
          value: value,
          caseSensitive: caseSensitive,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameLessThanOrEqualTo(
    String? value, {
    bool caseSensitive = true,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        LessOrEqualCondition(
          property: 1,
          value: value,
          caseSensitive: caseSensitive,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameBetween(
    String? lower,
    String? upper, {
    bool caseSensitive = true,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        BetweenCondition(
          property: 1,
          lower: lower,
          upper: upper,
          caseSensitive: caseSensitive,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameStartsWith(
    String value, {
    bool caseSensitive = true,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        StartsWithCondition(
          property: 1,
          value: value,
          caseSensitive: caseSensitive,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameEndsWith(
    String value, {
    bool caseSensitive = true,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        EndsWithCondition(
          property: 1,
          value: value,
          caseSensitive: caseSensitive,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameContains(
      String value,
      {bool caseSensitive = true}) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        ContainsCondition(
          property: 1,
          value: value,
          caseSensitive: caseSensitive,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameMatches(
      String pattern,
      {bool caseSensitive = true}) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        MatchesCondition(
          property: 1,
          wildcard: pattern,
          caseSensitive: caseSensitive,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameIsEmpty() {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        const EqualCondition(
          property: 1,
          value: '',
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> nameIsNotEmpty() {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        const GreaterCondition(
          property: 1,
          value: '',
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition>
      sourceOfSupplyIsNull() {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(const IsNullCondition(property: 2));
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition>
      sourceOfSupplyIsNotNull() {
    return QueryBuilder.apply(not(), (query) {
      return query.addFilterCondition(const IsNullCondition(property: 2));
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition>
      sourceOfSupplyIsEmpty() {
    return not().group(
      (q) => q.sourceOfSupplyIsNull().or().sourceOfSupplyIsNotEmpty(),
    );
  }

  QueryBuilder<Material, Material, QAfterFilterCondition>
      sourceOfSupplyIsNotEmpty() {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        const GreaterOrEqualCondition(property: 2, value: null),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> averagePriceIsNull() {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(const IsNullCondition(property: 3));
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition>
      averagePriceIsNotNull() {
    return QueryBuilder.apply(not(), (query) {
      return query.addFilterCondition(const IsNullCondition(property: 3));
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> averagePriceEqualTo(
    double? value, {
    double epsilon = Filter.epsilon,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        EqualCondition(
          property: 3,
          value: value,
          epsilon: epsilon,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition>
      averagePriceGreaterThan(
    double? value, {
    double epsilon = Filter.epsilon,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        GreaterCondition(
          property: 3,
          value: value,
          epsilon: epsilon,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition>
      averagePriceGreaterThanOrEqualTo(
    double? value, {
    double epsilon = Filter.epsilon,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        GreaterOrEqualCondition(
          property: 3,
          value: value,
          epsilon: epsilon,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> averagePriceLessThan(
    double? value, {
    double epsilon = Filter.epsilon,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        LessCondition(
          property: 3,
          value: value,
          epsilon: epsilon,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition>
      averagePriceLessThanOrEqualTo(
    double? value, {
    double epsilon = Filter.epsilon,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        LessOrEqualCondition(
          property: 3,
          value: value,
          epsilon: epsilon,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> averagePriceBetween(
    double? lower,
    double? upper, {
    double epsilon = Filter.epsilon,
  }) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        BetweenCondition(
          property: 3,
          lower: lower,
          upper: upper,
          epsilon: epsilon,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> idEqualTo(
    int value,
  ) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        EqualCondition(
          property: 0,
          value: value,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> idGreaterThan(
    int value,
  ) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        GreaterCondition(
          property: 0,
          value: value,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition>
      idGreaterThanOrEqualTo(
    int value,
  ) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        GreaterOrEqualCondition(
          property: 0,
          value: value,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> idLessThan(
    int value,
  ) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        LessCondition(
          property: 0,
          value: value,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> idLessThanOrEqualTo(
    int value,
  ) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        LessOrEqualCondition(
          property: 0,
          value: value,
        ),
      );
    });
  }

  QueryBuilder<Material, Material, QAfterFilterCondition> idBetween(
    int lower,
    int upper,
  ) {
    return QueryBuilder.apply(this, (query) {
      return query.addFilterCondition(
        BetweenCondition(
          property: 0,
          lower: lower,
          upper: upper,
        ),
      );
    });
  }
}

extension MaterialQueryObject
    on QueryBuilder<Material, Material, QFilterCondition> {}

extension MaterialQuerySortBy on QueryBuilder<Material, Material, QSortBy> {
  QueryBuilder<Material, Material, QAfterSortBy> sortByName(
      {bool caseSensitive = true}) {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(
        1,
        caseSensitive: caseSensitive,
      );
    });
  }

  QueryBuilder<Material, Material, QAfterSortBy> sortByNameDesc(
      {bool caseSensitive = true}) {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(
        1,
        sort: Sort.desc,
        caseSensitive: caseSensitive,
      );
    });
  }

  QueryBuilder<Material, Material, QAfterSortBy> sortByAveragePrice() {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(3);
    });
  }

  QueryBuilder<Material, Material, QAfterSortBy> sortByAveragePriceDesc() {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(3, sort: Sort.desc);
    });
  }

  QueryBuilder<Material, Material, QAfterSortBy> sortById() {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(0);
    });
  }

  QueryBuilder<Material, Material, QAfterSortBy> sortByIdDesc() {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(0, sort: Sort.desc);
    });
  }
}

extension MaterialQuerySortThenBy
    on QueryBuilder<Material, Material, QSortThenBy> {
  QueryBuilder<Material, Material, QAfterSortBy> thenByName(
      {bool caseSensitive = true}) {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(1, caseSensitive: caseSensitive);
    });
  }

  QueryBuilder<Material, Material, QAfterSortBy> thenByNameDesc(
      {bool caseSensitive = true}) {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(1, sort: Sort.desc, caseSensitive: caseSensitive);
    });
  }

  QueryBuilder<Material, Material, QAfterSortBy> thenByAveragePrice() {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(3);
    });
  }

  QueryBuilder<Material, Material, QAfterSortBy> thenByAveragePriceDesc() {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(3, sort: Sort.desc);
    });
  }

  QueryBuilder<Material, Material, QAfterSortBy> thenById() {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(0);
    });
  }

  QueryBuilder<Material, Material, QAfterSortBy> thenByIdDesc() {
    return QueryBuilder.apply(this, (query) {
      return query.addSortBy(0, sort: Sort.desc);
    });
  }
}

extension MaterialQueryWhereDistinct
    on QueryBuilder<Material, Material, QDistinct> {
  QueryBuilder<Material, Material, QAfterDistinct> distinctByName(
      {bool caseSensitive = true}) {
    return QueryBuilder.apply(this, (query) {
      return query.addDistinctBy(1, caseSensitive: caseSensitive);
    });
  }

  QueryBuilder<Material, Material, QAfterDistinct> distinctByAveragePrice() {
    return QueryBuilder.apply(this, (query) {
      return query.addDistinctBy(3);
    });
  }
}

extension MaterialQueryProperty1
    on QueryBuilder<Material, Material, QProperty> {
  QueryBuilder<Material, String?, QAfterProperty> nameProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(1);
    });
  }

  QueryBuilder<Material, List<IdValueColor>?, QAfterProperty>
      sourceOfSupplyProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(2);
    });
  }

  QueryBuilder<Material, double?, QAfterProperty> averagePriceProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(3);
    });
  }

  QueryBuilder<Material, int, QAfterProperty> idProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(0);
    });
  }
}

extension MaterialQueryProperty2<R>
    on QueryBuilder<Material, R, QAfterProperty> {
  QueryBuilder<Material, (R, String?), QAfterProperty> nameProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(1);
    });
  }

  QueryBuilder<Material, (R, List<IdValueColor>?), QAfterProperty>
      sourceOfSupplyProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(2);
    });
  }

  QueryBuilder<Material, (R, double?), QAfterProperty> averagePriceProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(3);
    });
  }

  QueryBuilder<Material, (R, int), QAfterProperty> idProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(0);
    });
  }
}

extension MaterialQueryProperty3<R1, R2>
    on QueryBuilder<Material, (R1, R2), QAfterProperty> {
  QueryBuilder<Material, (R1, R2, String?), QOperations> nameProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(1);
    });
  }

  QueryBuilder<Material, (R1, R2, List<IdValueColor>?), QOperations>
      sourceOfSupplyProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(2);
    });
  }

  QueryBuilder<Material, (R1, R2, double?), QOperations>
      averagePriceProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(3);
    });
  }

  QueryBuilder<Material, (R1, R2, int), QOperations> idProperty() {
    return QueryBuilder.apply(this, (query) {
      return query.addProperty(0);
    });
  }
}

// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

Material _$MaterialFromJson(Map<String, dynamic> json) => Material()
  ..id = (json['id'] as num).toInt()
  ..name = json['Name Material'] as String?
  ..sourceOfSupply = (json['Bezugsquelle'] as List<dynamic>?)
      ?.map((e) => IdValueColor.fromJson(e as Map<String, dynamic>))
      .toList()
  ..averagePrice = (json['Durchschnittlicher Preis'] as num?)?.toDouble();

Map<String, dynamic> _$MaterialToJson(Material instance) => <String, dynamic>{
      'id': instance.id,
      'Name Material': instance.name,
      'Bezugsquelle': instance.sourceOfSupply?.map((e) => e.toJson()).toList(),
      'Durchschnittlicher Preis': instance.averagePrice,
    };
