enum CycleEnum { Month('Month'), Year('Year'); private String pricingCycle; CycleEnum(String pricingCycle) { this.pricingCycle = pricingCycle } public String getPricingCycle() { return pricingCycle; } public static CycleEnum valueOfName( String type ) { return values().find { CycleEnum it -> it.pricingCycle == type } } }
转载于:https://blog.51cto.com/wangyuelucky/1741085