如果您查看您的代码,您会发现一种叫做“代码气味”(重复代码)的东西。您拥有自己的三个参数结构,这些参数不断重复:步骤、关键字和对象。只是看到我建议把它放在一个类中,以便拥有:
public class YourClass{
private String keyword;
private String step;
private String object;
//It´s your choice whether to have setters or have everything in through constructor
public String getKeyword(){
return this.keyword;
}
.... //continue with getters for step and object
}
现在您可以拥有 hashMap 的常规结构,以便拥有 Map 这意味着它们用于查看您的地图的关键将是一个字符串“TC_01”、“TC_02”,当您返回 YourClass 时,您所要做的就是调用。 getKeyword() ... 以获取您的其余信息。
例子:
YourClass yourClassVariable = new YourClass();
yourClassVariable.setStep("TS01");
yourClassVariable.setKeyword("navigate");
yourClassVariable.setObject("search_fare");
Map<String,YourClass> mp=new HashMap<String, YourClass>();
// adding or setting elements in Map by put method key and value pair
mp.put("TC_01", yourClassVariable);
:)