// ORDERED("已排单"),INITSTATUS("初始状态"),
Scanner scanner = new Scanner(System.in);
String s = scanner.next();
String[] array = s.split(",");
System.out.println("请输入Set的String名称:");
String setName = scanner.next();
System.out.println("请输入枚举类的名称: ");
String menuName = scanner.next();
int count = 0 ;
for (String s1 : array) {
String[] menu = s1.split("\\(");
ArrayList<String> strings = new ArrayList<>();
if (count != 0){
strings.add("else");
}
strings.add("if (");
strings.add(menuName+"."+menu[0]+".getName().equals("+setName+"))");
strings.add("{");
strings.add("this."+setName+"="+menuName+".valueOf(\""+menu[0]+"\");}");
String join = StringUtils.join(strings, " ");
System.out.println(join);
count++;
}
自定义搜索方法:
@AllArgsConstructor
@Getter
public enum AuditStatus {
//合格,不合格,保留,让步接收 ,接收、挑选(全检)、判退
UNQUALIFIED("不合格"),QUALIFIED("合格"),RETAIN("保留"),RECEIVE("接收"),MISEJECTION("让步接收"),CHOOSE("挑选"),REJECT("判退");
private final String name;
private static final Map<String,AuditStatus> orgAuditStatus = new HashMap<>();
static {
for (AuditStatus value : AuditStatus.values()) {
orgAuditStatus.put(value.getName(),value);
}
}
public static AuditStatus find(String name){
return orgAuditStatus.get(name);
}
}