fromChainAndTemplateFileSetting static method

Danger<List<ObjectSymbol>, ChainException> fromChainAndTemplateFileSetting(
  1. Chain chain,
  2. TemplateFileSetting tempalteFileSetting
)

Implementation

static Danger<List<ObjectSymbol>, ChainException> fromChainAndTemplateFileSetting(Chain chain, TemplateFileSetting tempalteFileSetting) {

    final log = Log(classLocation: ObjectSymbol, functionLocation: 'fromChainAndTemplateFileSetting');

    final List<ObjectSymbol> list = [];

    for (final i in tempalteFileSetting.objectDefinitions) {

        final getResult = chain.getOptionAsSingleString(i.name);
        log.add(getResult);
        if (getResult is! Success<String, ChainExceptionIJK>) return Failure(getResult.asException, log);

        final chainResult = Chain.fromSource(getResult.wrapped);
        log.add(chainResult);
        if (chainResult is! Success<Chain, ChainSyntaxException>) return Failure(chainResult.asException, log);

        final dataTypeResult = CitrusObject.fromChainAndObjectDefinition(chainResult.wrapped, i);
        log.add(dataTypeResult);
        if (dataTypeResult is! Success<CitrusObject, ChainException>) return Failure(dataTypeResult.asException, log);

        final result = ObjectSymbol(i.name, dataTypeResult.wrapped);

        list.add(result);

    }

    return Success(list, log);

}