代码如下:
package catf.component.http.model; /**
* @Auther:gongxingrui
* @Date:2018-04-17
* @Description: 规范结果匹配的类型
**/
public enum CheckType {
EQUALS("equals", 1),
CONTAINS("contains", 2),
REGEX("regex", 3); private String value;
private int id; private CheckType(String value, int id) {
this.value = value;
this.id = id;
} public String getValue() {
return value;
} public int getId() {
return id;
} @Override
public String toString() {
return "CheckType{" +
"value='" + value + '\'' +
", id=" + id +
'}';
}
}
测试类:
package catf.component.http.model; import org.junit.Test; public class TestCheckType {
@Test
public void test() {
System.out.println("equals:" + CheckType.EQUALS.getId() + " " + CheckType.EQUALS.getValue());
CheckType[] checkTypes = CheckType.values();
for (CheckType c : checkTypes) {
System.out.print(c.toString() + "、");
}
CheckType c = CheckType.CONTAINS;
System.out.println("\n" + c.getValue());
}
}