public enum EnumDemo {
LAUNCH(1, "launch event", "e_l"),//launch事件,表示第一次访问
PAGEVIEW(2, "page view event", "e_pv"),//页面浏览事件
CHARGEREQUEST(3, "charge request event", "e_crt"),//订单生产事件
CHARGESUCCESS(4, "charge success event", "e_cs"),//订单成功支付事件
CHARGEREFOUND(5, "charge refound event", "e_cr"),//订单退款事件
EVENT(6, "event duration event", "e_e")//事件
;
public final int id;//id唯一标识
public final String name;//名称
public final String alias;//别名,用于数据收集的简写
private EnumDemo(int id, String name, String alias)//枚举类型的构造方法一定是私有的
{
this.id = id;
this.name = name;
this.alias = alias;
}
public static void main(String[] args) {
EnumDemo[] values=EnumDemo.values();
for(EnumDemo value:values)
{
System.out.println(value+" "+value.id+" "+value.name+" "+value.alias);
}
}
}
输出:
LAUNCH 1 launch event e_l
PAGEVIEW 2 page view event e_pv
CHARGEREQUEST 3 charge request event e_crt
CHARGESUCCESS 4 charge success event e_cs
CHARGEREFOUND 5 charge refound event e_cr
EVENT 6 event duration event e_e