fromYamlMapAndKey static method

Danger<ObjectValuable, BpriverYamlException> fromYamlMapAndKey(
  1. YamlMap yamlMap,
  2. String key
)

Implementation

static Danger<ObjectValuable, BpriverYamlException> fromYamlMapAndKey(YamlMap yamlMap, String key) {

    final log = Log(classLocation: ObjectValuable, functionLocation: 'fromYamlMapAndKey');

    final actionResult = BpriverYaml.getByKeyFromYamlMapThenAction<Danger<ObjectValuable, BpriverYamlException>>(yamlMap, key,
    thenString: (value) => Success(CitrusText(value)),
    thenBoolean: (value) => Success(CitrusFlag(value)),
    thenList: (value) {

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

        return Success(CitrusTextArray.from(parseResult.wrapped));

    });
    log.add(actionResult);
    if (actionResult is! Success<Danger<ObjectValuable, BpriverYamlException>, BpriverYamlExceptionDH>) return Failure(actionResult.asException, log);

    final result = actionResult.wrapped;
    log.add(result);
    if (result is! Success<ObjectValuable, BpriverYamlException>) return Failure(result.asException, log);

    return Success(result.wrapped, log);

}