fromYamlMap static method

Danger<EnumerationFileSetting, BpriverYamlException> fromYamlMap(
  1. YamlMap yamlMap
)

ここで記述した引数は共通で利用される. global_argument: generateMode: 'overwrite' generateLocation: './' templateFileLocation: 'xxx\yyy\zzz' packageName: 'bpriver warden' applicationName: 'warden' /// これは chain の List

citrus で利用できる command を指定(これなら重複しない).

generate: # 複雑な引数は global_arguments で記述すれば管理しやすくなる. # 二つの generate command が上から順に実行される. # chain として読み込まれる. "--templateFileName 'application.yaml'", "--templateFileName 'language.yaml'",

generate 以外の commnad も管理できる.

tree:

Implementation

static Danger<EnumerationFileSetting, BpriverYamlException> fromYamlMap(YamlMap yamlMap) {

    final log = Log(classLocation: EnumerationFileSetting, functionLocation: 'fromYamlMap');

    final globalArgumentResult = BpriverYaml.getByKeyFromYamlMapAsT<YamlMap>(yamlMap, 'global_argument');
    log.add(globalArgumentResult);
    if (globalArgumentResult is! Success<YamlMap, BpriverYamlExceptionDE>) return Failure(globalArgumentResult.asException, log);
    final globalArgumentYamlMap = globalArgumentResult.wrapped;

    final List<GlobalArgument> globalArgumentList = [];

    for (final i in globalArgumentYamlMap.entries) {

        final key = i.key as String;

        final thenActionResult = BpriverYaml.getByKeyFromYamlMapThenAction<Danger<GlobalArgument, BpriverYamlExceptionF>>(globalArgumentYamlMap, key,
        thenBoolean: (value) => Success(FlagGlobalArgument(key, value)),
        thenString: (value) => Success(SingleGlobalArgument(key, value)),
        thenNumber: (value) => Success(SingleGlobalArgument(key, value.toString())),
        thenNull: () => Success(SingleGlobalArgument(key, '')),
        thenList: (value) {

            final result = BpriverYaml.parseYamlListAsT<String>(value);
            log.add(result);
            if (result is! Success<List<String>, BpriverYamlExceptionF>) return Failure(result.asException);

            return Success(MultipleGlobalArgument(key, result.wrapped), log);
        });
        log.add(thenActionResult);
        if (thenActionResult is! Success<Danger<GlobalArgument, BpriverYamlExceptionF>, BpriverYamlExceptionDH>) return Failure(thenActionResult.asException, log);
        final result = thenActionResult.wrapped;
        if (result is! Success<GlobalArgument, BpriverYamlExceptionF>) return Failure(result.asException, log);

        globalArgumentList.add(result.wrapped);

    }

    final generateResult = BpriverYaml.getByKeyFromYamlMapAsT<YamlList>(yamlMap, 'generate');
    log.add(generateResult);
    if (generateResult is! Success<YamlList, BpriverYamlExceptionDE>) return Failure(generateResult.asException, log);

    final generateListResult = BpriverYaml.parseYamlListAsT<String>(generateResult.wrapped);
    log.add(generateListResult);
    if (generateListResult is! Success<List<String>, BpriverYamlExceptionF>) return Failure(generateListResult.asException, log);

    final result = EnumerationFileSetting(globalArgumentList, generateListResult.wrapped);

    return Success(result, log);

}