wyatt-bricks/tools/brick_generator/lib/models/boolean_file_system.dart

70 lines
2.1 KiB
Dart

// 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 <https://www.gnu.org/licenses/>.
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 folders = BooleanFileSystemVariable.fromYaml(
source.nodes[_foldersKey] as YamlMap?,
);
final files = BooleanFileSystemVariable.fromYaml(
source.nodes[_filesKey] as YamlMap?,
);
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)';
}