//单一事件直接调用
public static String todo(String day) {
CHeckDay cHeckDay = new CHeckDay();
return cHeckDay.day(DayEnum.valueOf(day));
}
//多事件重复使用
public static String todoNew (String day) {
CHeckDay cHeckDay = new CHeckDay();
return cHeckDay.dayNew(DayEnumNew.valueOf(day));
}
public static void main(String[] args) {
System.out.println(todoNew(("one")));
}
package com.eaton.guan.cms.config;
/**
* @Author : hyx
* @CreateDate : 2024-01-01 23:12
*/
public class CHeckDay {
public String day(DayEnum dayEnum) {
return dayEnum.todo();
}
public String dayNew(DayEnumNew dayEnum) {
return dayEnum.todo();
}
}
package com.eaton.guan.cms.config;
/**
* @Author : hyx
* @CreateDate : 2024-01-01 23:13
*/
public enum DayEnum {
one {
@Override
public String todo() {
return "这个是一";
}
};
public abstract String todo();
}
package com.eaton.guan.cms.config;
/**
* @Author : hyx
* @CreateDate : 2024-01-01 23:22
*/
public enum DayEnumNew {
one("one",Type.one),
two("one",Type.one);
private final String value;
private final Type type;
DayEnumNew(String value, Type type) {
this.value = value;
this.type = type;
}
String todo(){
return type.todo();
};
public enum Type {
one{
@Override
public String todo() {
return "这是一";
}
};
public abstract String todo();
}
}