// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'database.dart';

// **************************************************************************
// FloorGenerator
// **************************************************************************

class $FloorDatabaseService {
  /// Creates a database builder for a persistent database.
  /// Once a database is built, you should keep a reference to it and re-use it.
  static _$DatabaseServiceBuilder databaseBuilder(String name) =>
      _$DatabaseServiceBuilder(name);

  /// Creates a database builder for an in memory database.
  /// Information stored in an in memory database disappears when the process is killed.
  /// Once a database is built, you should keep a reference to it and re-use it.
  static _$DatabaseServiceBuilder inMemoryDatabaseBuilder() =>
      _$DatabaseServiceBuilder(null);
}

class _$DatabaseServiceBuilder {
  _$DatabaseServiceBuilder(this.name);

  final String? name;

  final List<Migration> _migrations = [];

  Callback? _callback;

  /// Adds migrations to the builder.
  _$DatabaseServiceBuilder addMigrations(List<Migration> migrations) {
    _migrations.addAll(migrations);
    return this;
  }

  /// Adds a database [Callback] to the builder.
  _$DatabaseServiceBuilder addCallback(Callback callback) {
    _callback = callback;
    return this;
  }

  /// Creates the database and initializes it.
  Future<DatabaseService> build() async {
    final path = name != null
        ? await sqfliteDatabaseFactory.getDatabasePath(name!)
        : ':memory:';
    final database = _$DatabaseService();
    database.database = await database.open(
      path,
      _migrations,
      _callback,
    );
    return database;
  }
}

class _$DatabaseService extends DatabaseService {
  _$DatabaseService([StreamController<String>? listener]) {
    changeListener = listener ?? StreamController<String>.broadcast();
  }

  PlayerDao? _playerDaoInstance;

  ClubDao? _clubDaoInstance;

  GroupDao? _groupDaoInstance;

  Future<sqflite.Database> open(String path, List<Migration> migrations,
      [Callback? callback]) async {
    final databaseOptions = sqflite.OpenDatabaseOptions(
      version: 1,
      onConfigure: (database) async {
        await database.execute('PRAGMA foreign_keys = ON');
        await callback?.onConfigure?.call(database);
      },
      onOpen: (database) async {
        await callback?.onOpen?.call(database);
      },
      onUpgrade: (database, startVersion, endVersion) async {
        await MigrationAdapter.runMigrations(
            database, startVersion, endVersion, migrations);

        await callback?.onUpgrade?.call(database, startVersion, endVersion);
      },
      onCreate: (database, version) async {
        await database.execute(
            'CREATE TABLE IF NOT EXISTS `players` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `firstName` TEXT NOT NULL, `lastName` TEXT NOT NULL, `birthday` TEXT NOT NULL, `email` TEXT NOT NULL, `phoneNumber` TEXT NOT NULL, `hitColor` TEXT NOT NULL, `createdAt` TEXT NOT NULL, `updatedAt` TEXT NOT NULL)');
        await database.execute(
            'CREATE TABLE IF NOT EXISTS `clubs` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT NOT NULL, `ownerFirstName` TEXT NOT NULL, `ownerLastName` TEXT NOT NULL, `createdAt` TEXT NOT NULL, `updatedAt` TEXT NOT NULL)');
        await database.execute(
            'CREATE TABLE IF NOT EXISTS `groups` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT NOT NULL, `description` TEXT NOT NULL, `clubId` INTEGER NOT NULL, `createdAt` TEXT NOT NULL, `updatedAt` TEXT NOT NULL, FOREIGN KEY (`clubId`) REFERENCES `clubs` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION)');

        await callback?.onCreate?.call(database, version);
      },
    );
    return sqfliteDatabaseFactory.openDatabase(path, options: databaseOptions);
  }

  @override
  PlayerDao get playerDao {
    return _playerDaoInstance ??= _$PlayerDao(database, changeListener);
  }

  @override
  ClubDao get clubDao {
    return _clubDaoInstance ??= _$ClubDao(database, changeListener);
  }

  @override
  GroupDao get groupDao {
    return _groupDaoInstance ??= _$GroupDao(database, changeListener);
  }
}

class _$PlayerDao extends PlayerDao {
  _$PlayerDao(this.database, this.changeListener)
      : _queryAdapter = QueryAdapter(database),
        _playerInsertionAdapter = InsertionAdapter(
            database,
            'players',
            (Player item) => <String, Object?>{
                  'id': item.id,
                  'firstName': item.firstName,
                  'lastName': item.lastName,
                  'birthday': _dateTimeConverter.encode(item.birthday),
                  'email': item.email,
                  'phoneNumber': item.phoneNumber,
                  'hitColor': item.hitColor,
                  'createdAt': _dateTimeConverter.encode(item.createdAt),
                  'updatedAt': _dateTimeConverter.encode(item.updatedAt)
                }),
        _playerUpdateAdapter = UpdateAdapter(
            database,
            'players',
            ['id'],
            (Player item) => <String, Object?>{
                  'id': item.id,
                  'firstName': item.firstName,
                  'lastName': item.lastName,
                  'birthday': _dateTimeConverter.encode(item.birthday),
                  'email': item.email,
                  'phoneNumber': item.phoneNumber,
                  'hitColor': item.hitColor,
                  'createdAt': _dateTimeConverter.encode(item.createdAt),
                  'updatedAt': _dateTimeConverter.encode(item.updatedAt)
                }),
        _playerDeletionAdapter = DeletionAdapter(
            database,
            'players',
            ['id'],
            (Player item) => <String, Object?>{
                  'id': item.id,
                  'firstName': item.firstName,
                  'lastName': item.lastName,
                  'birthday': _dateTimeConverter.encode(item.birthday),
                  'email': item.email,
                  'phoneNumber': item.phoneNumber,
                  'hitColor': item.hitColor,
                  'createdAt': _dateTimeConverter.encode(item.createdAt),
                  'updatedAt': _dateTimeConverter.encode(item.updatedAt)
                });

  final sqflite.DatabaseExecutor database;

  final StreamController<String> changeListener;

  final QueryAdapter _queryAdapter;

  final InsertionAdapter<Player> _playerInsertionAdapter;

  final UpdateAdapter<Player> _playerUpdateAdapter;

  final DeletionAdapter<Player> _playerDeletionAdapter;

  @override
  Future<List<Player>> findAllPlayers() async {
    return _queryAdapter.queryList('Select * from players',
        mapper: (Map<String, Object?> row) => Player(
            row['id'] as int?,
            row['firstName'] as String,
            row['lastName'] as String,
            _dateTimeConverter.decode(row['birthday'] as String),
            row['email'] as String,
            row['phoneNumber'] as String,
            row['hitColor'] as String,
            createdAt:
                _dateTimeNullConverter.decode(row['createdAt'] as String),
            updatedAt:
                _dateTimeNullConverter.decode(row['updatedAt'] as String)));
  }

  @override
  Future<Player?> findPlayerById(int id) async {
    return _queryAdapter.query('Select * from players where id = ?1',
        mapper: (Map<String, Object?> row) => Player(
            row['id'] as int?,
            row['firstName'] as String,
            row['lastName'] as String,
            _dateTimeConverter.decode(row['birthday'] as String),
            row['email'] as String,
            row['phoneNumber'] as String,
            row['hitColor'] as String,
            createdAt:
                _dateTimeNullConverter.decode(row['createdAt'] as String),
            updatedAt:
                _dateTimeNullConverter.decode(row['updatedAt'] as String)),
        arguments: [id]);
  }

  @override
  Future<int?> countPlayers() async {
    await _queryAdapter.queryNoReturn('Select COUNT(*) from players');
  }

  @override
  Future<void> insertPlayer(Player player) async {
    await _playerInsertionAdapter.insert(player, OnConflictStrategy.abort);
  }

  @override
  Future<void> updatePlayer(Player player) async {
    await _playerUpdateAdapter.update(player, OnConflictStrategy.abort);
  }

  @override
  Future<void> deletePlayer(Player player) async {
    await _playerDeletionAdapter.delete(player);
  }
}

class _$ClubDao extends ClubDao {
  _$ClubDao(this.database, this.changeListener)
      : _queryAdapter = QueryAdapter(database),
        _clubInsertionAdapter = InsertionAdapter(
            database,
            'clubs',
            (Club item) => <String, Object?>{
                  'id': item.id,
                  'name': item.name,
                  'ownerFirstName': item.ownerFirstName,
                  'ownerLastName': item.ownerLastName,
                  'createdAt': _dateTimeConverter.encode(item.createdAt),
                  'updatedAt': _dateTimeConverter.encode(item.updatedAt)
                }),
        _clubUpdateAdapter = UpdateAdapter(
            database,
            'clubs',
            ['id'],
            (Club item) => <String, Object?>{
                  'id': item.id,
                  'name': item.name,
                  'ownerFirstName': item.ownerFirstName,
                  'ownerLastName': item.ownerLastName,
                  'createdAt': _dateTimeConverter.encode(item.createdAt),
                  'updatedAt': _dateTimeConverter.encode(item.updatedAt)
                }),
        _clubDeletionAdapter = DeletionAdapter(
            database,
            'clubs',
            ['id'],
            (Club item) => <String, Object?>{
                  'id': item.id,
                  'name': item.name,
                  'ownerFirstName': item.ownerFirstName,
                  'ownerLastName': item.ownerLastName,
                  'createdAt': _dateTimeConverter.encode(item.createdAt),
                  'updatedAt': _dateTimeConverter.encode(item.updatedAt)
                });

  final sqflite.DatabaseExecutor database;

  final StreamController<String> changeListener;

  final QueryAdapter _queryAdapter;

  final InsertionAdapter<Club> _clubInsertionAdapter;

  final UpdateAdapter<Club> _clubUpdateAdapter;

  final DeletionAdapter<Club> _clubDeletionAdapter;

  @override
  Future<List<Club>> findAllClubs() async {
    return _queryAdapter.queryList('Select * from clubs',
        mapper: (Map<String, Object?> row) => Club(
            row['id'] as int?,
            row['name'] as String,
            row['ownerFirstName'] as String,
            row['ownerLastName'] as String,
            createdAt:
                _dateTimeNullConverter.decode(row['createdAt'] as String),
            updatedAt:
                _dateTimeNullConverter.decode(row['updatedAt'] as String)));
  }

  @override
  Future<Club?> findClubById(int id) async {
    return _queryAdapter.query('Select * from clubs where id = ?1',
        mapper: (Map<String, Object?> row) => Club(
            row['id'] as int?,
            row['name'] as String,
            row['ownerFirstName'] as String,
            row['ownerLastName'] as String,
            createdAt:
                _dateTimeNullConverter.decode(row['createdAt'] as String),
            updatedAt:
                _dateTimeNullConverter.decode(row['updatedAt'] as String)),
        arguments: [id]);
  }

  @override
  Future<int?> countClubs() async {
    await _queryAdapter.queryNoReturn('Select COUNT(*) from clubs');
  }

  @override
  Future<void> insertClub(Club club) async {
    await _clubInsertionAdapter.insert(club, OnConflictStrategy.abort);
  }

  @override
  Future<void> updateClub(Club club) async {
    await _clubUpdateAdapter.update(club, OnConflictStrategy.abort);
  }

  @override
  Future<void> deleteClub(Club club) async {
    await _clubDeletionAdapter.delete(club);
  }
}

class _$GroupDao extends GroupDao {
  _$GroupDao(this.database, this.changeListener)
      : _queryAdapter = QueryAdapter(database),
        _groupInsertionAdapter = InsertionAdapter(
            database,
            'groups',
            (Group item) => <String, Object?>{
                  'id': item.id,
                  'name': item.name,
                  'description': item.description,
                  'clubId': item.clubId,
                  'createdAt': _dateTimeConverter.encode(item.createdAt),
                  'updatedAt': _dateTimeConverter.encode(item.updatedAt)
                }),
        _groupUpdateAdapter = UpdateAdapter(
            database,
            'groups',
            ['id'],
            (Group item) => <String, Object?>{
                  'id': item.id,
                  'name': item.name,
                  'description': item.description,
                  'clubId': item.clubId,
                  'createdAt': _dateTimeConverter.encode(item.createdAt),
                  'updatedAt': _dateTimeConverter.encode(item.updatedAt)
                }),
        _groupDeletionAdapter = DeletionAdapter(
            database,
            'groups',
            ['id'],
            (Group item) => <String, Object?>{
                  'id': item.id,
                  'name': item.name,
                  'description': item.description,
                  'clubId': item.clubId,
                  'createdAt': _dateTimeConverter.encode(item.createdAt),
                  'updatedAt': _dateTimeConverter.encode(item.updatedAt)
                });

  final sqflite.DatabaseExecutor database;

  final StreamController<String> changeListener;

  final QueryAdapter _queryAdapter;

  final InsertionAdapter<Group> _groupInsertionAdapter;

  final UpdateAdapter<Group> _groupUpdateAdapter;

  final DeletionAdapter<Group> _groupDeletionAdapter;

  @override
  Future<List<Group>> findAllGroups() async {
    return _queryAdapter.queryList('Select * from groups',
        mapper: (Map<String, Object?> row) => Group(
            row['id'] as int?,
            row['name'] as String,
            row['description'] as String,
            row['clubId'] as int,
            createdAt:
                _dateTimeNullConverter.decode(row['createdAt'] as String),
            updatedAt:
                _dateTimeNullConverter.decode(row['updatedAt'] as String)));
  }

  @override
  Future<Group?> findGroupById(int id) async {
    return _queryAdapter.query('Select * from groups where id = ?1',
        mapper: (Map<String, Object?> row) => Group(
            row['id'] as int?,
            row['name'] as String,
            row['description'] as String,
            row['clubId'] as int,
            createdAt:
                _dateTimeNullConverter.decode(row['createdAt'] as String),
            updatedAt:
                _dateTimeNullConverter.decode(row['updatedAt'] as String)),
        arguments: [id]);
  }

  @override
  Future<int?> countGroups() async {
    await _queryAdapter.queryNoReturn('Select COUNT(*) from groups');
  }

  @override
  Future<void> insertGroup(Group group) async {
    await _groupInsertionAdapter.insert(group, OnConflictStrategy.abort);
  }

  @override
  Future<void> updateGroup(Group grouup) async {
    await _groupUpdateAdapter.update(grouup, OnConflictStrategy.abort);
  }

  @override
  Future<void> deleteGroup(Group group) async {
    await _groupDeletionAdapter.delete(group);
  }
}

// ignore_for_file: unused_element
final _dateTimeConverter = DateTimeConverter();
final _dateTimeNullConverter = DateTimeNullConverter();
final _nullableIntConverter = NullableIntConverter();
