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

org.sahagin.share.srctree.code.TestStep Maven / Gradle / Ivy

The newest version!
package org.sahagin.share.srctree.code;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.sahagin.share.yaml.YamlConvertException;
import org.sahagin.share.yaml.YamlUtils;

public class TestStep extends Code {
    public static final String TYPE = "step";

    private String label;
    private String text;
    private List stepBody = new ArrayList<>(32);

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public List getStepBody() {
        return stepBody;
    }

    public void addStepBody(CodeLine step) {
        stepBody.add(step);
    }

    @Override
    protected String getType() {
        return TYPE;
    }

    @Override
    public Map toYamlObject() {
        Map result = super.toYamlObject();
        if (label != null) {
            result.put("label", label);
        }
        if (text != null) {
            result.put("text", text);
        }
        if (!stepBody.isEmpty()) {
            result.put("body", YamlUtils.toYamlObjectList(stepBody));
        }

        return result;
    }

    @Override
    public void fromYamlObject(Map yamlObject)
            throws YamlConvertException {
        super.fromYamlObject(yamlObject);
        label = YamlUtils.getStrValue(yamlObject, "label", true);
        text = YamlUtils.getStrValue(yamlObject, "text", true);
        List> stepBodyYamlObj = YamlUtils.getYamlObjectListValue(yamlObject, "body", true);
        stepBody = new ArrayList<>(stepBodyYamlObj.size());
        for (Map stepYamlObj : stepBodyYamlObj) {
            CodeLine step = new CodeLine();
            step.fromYamlObject(stepYamlObj);
            stepBody.add(step);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy