All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hyperfoil.tools.qdup.config.yaml.CmdWithElseConstruct Maven / Gradle / Ivy

Go to download

Coordinate multiple terminal shell connections for queuing performance tests and collecting output files

There is a newer version: 0.8.3
Show newest version
package io.hyperfoil.tools.qdup.config.yaml;

import io.hyperfoil.tools.qdup.cmd.Cmd;
import io.hyperfoil.tools.qdup.cmd.CmdWithElse;
import io.hyperfoil.tools.yaup.json.Json;
import org.yaml.snakeyaml.error.YAMLException;
import org.yaml.snakeyaml.nodes.SequenceNode;

import java.util.function.Function;

public class CmdWithElseConstruct extends CmdConstruct{
    public CmdWithElseConstruct(String tag, FromString fromString, Function fromJson, String... keys) {
        super(tag, fromString, fromJson, keys);
        this.addTopLevelkey("else",(cmd,node)->{
            if(cmd instanceof CmdWithElse && node instanceof SequenceNode){
                CmdWithElse elseCmd = (CmdWithElse)cmd;
                SequenceNode sequenceNode = (SequenceNode)node;
                this.sequenceToCmds(sequenceNode).forEach(elseCmd::onElse);
            }else{
                throw new YAMLException("else requires a sequence of commands\n"+node.getStartMark()+"\n cmd: "+cmd+"\nnode: "+node);
            }
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy