org.sahagin.share.srctree.code.SubMethodInvoke Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sahagin Show documentation
Show all versions of sahagin Show documentation
Sahagin makes your Selenium script more readable and maintainable.
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.srctree.TestMethod;
import org.sahagin.share.yaml.YamlUtils;
import org.sahagin.share.yaml.YamlConvertException;
public class SubMethodInvoke extends Code {
public static final String TYPE = "method";
private String subMethodKey;
private TestMethod subMethod;
private List args = new ArrayList<>(4);
private Code thisInstance;
// whether the actual invoked method is the child method of the method for the subMethodKey
private boolean childInvoke = false;
public String getSubMethodKey() {
return subMethodKey;
}
public void setSubMethodKey(String subMethodKey) {
this.subMethodKey = subMethodKey;
}
public TestMethod getSubMethod() {
return subMethod;
}
public void setSubMethod(TestMethod subMethod) {
this.subMethod = subMethod;
}
public List getArgs() {
return args;
}
public void addArg(Code arg) {
args.add(arg);
}
public Code getThisInstance() {
return thisInstance;
}
public void setThisInstance(Code thisInstance) {
this.thisInstance = thisInstance;
}
public boolean isChildInvoke() {
return childInvoke;
}
public void setChildInvoke(boolean childInvoke) {
this.childInvoke = childInvoke;
}
@Override
protected String getType() {
return TYPE;
}
@Override
public Map toYamlObject() {
Map result = super.toYamlObject();
result.put("methodKey", subMethodKey);
if (!args.isEmpty()) {
result.put("args", YamlUtils.toYamlObjectList(args));
}
if (thisInstance != null) {
result.put("thisInstance", YamlUtils.toYamlObject(thisInstance));
}
if (childInvoke) {
result.put("childInvoke", childInvoke);
}
return result;
}
@Override
public void fromYamlObject(Map yamlObject)
throws YamlConvertException {
super.fromYamlObject(yamlObject);
subMethodKey = YamlUtils.getStrValue(yamlObject, "methodKey");
subMethod = null;
List