// ignore_for_file: public_member_api_docs, sort_constructors_first // Copyright (C) 2023 WYATT GROUP // Please see the AUTHORS file for details. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . import 'package:brick_generator/models/boolean_file_system_variable.dart'; import 'package:yaml/yaml.dart'; const _foldersKey = 'folders'; const _filesKey = 'files'; class BooleanFileSystem { BooleanFileSystem({ required this.booleanName, required this.folders, required this.files, }); factory BooleanFileSystem.fromYaml(String key, YamlMap? source) { if (source == null) { throw ArgumentError.notNull('source'); } final variableName = key; final foldersMap = source.nodes[_foldersKey] as YamlMap?; final folders = (foldersMap != null) ? BooleanFileSystemVariable.fromYaml( source.nodes[_foldersKey] as YamlMap?, ) : BooleanFileSystemVariable.empty(); final filesMap = source.nodes[_filesKey] as YamlMap?; final files = (filesMap != null) ? BooleanFileSystemVariable.fromYaml( source.nodes[_filesKey] as YamlMap?, ) : BooleanFileSystemVariable.empty(); return BooleanFileSystem( booleanName: variableName, folders: folders, files: files, ); } String booleanName; BooleanFileSystemVariable folders; BooleanFileSystemVariable files; BooleanFileSystem copyWith({ String? booleanName, BooleanFileSystemVariable? folders, BooleanFileSystemVariable? files, }) => BooleanFileSystem( booleanName: booleanName ?? this.booleanName, folders: folders ?? this.folders, files: files ?? this.files, ); @override String toString() => 'BooleanFileSystem(booleanName: $booleanName, ' 'folders: $folders, files: $files)'; }