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 = [...tempalteFileSetting.constantObjectSymbols];

    for (final i in tempalteFileSetting.objectDefinitions) {

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

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

        final dataTypeResult = CitrusObject.fromChain(chainResult.wrapped.bodyList);

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

        list.add(result);

    }

    return Success(list, log);

}