Enum扩展,可以包含多个属性

本文介绍了一个配置信息枚举类型的定义及其使用方法。该枚举包括邀请奖励积分、返利百分比、验证码过期时间等配置项,并提供了获取配置描述的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/**
* 配置信息
* */
public enum ConfigType {

PointsInvetee(5,"points.Invetee","30000","被邀请人获得的奖励积分",true),
PointsInveter(6,"points.Inveter","20000","邀请人获得的奖励积分",true),
RebateFatherPercent(7,"percent.rebate.father","0.2","多级返利-父节点获得返利百分比",true),
RebateGrandapaPercent(8,"percent.rebate.grandapa","0.1","多级返利-祖父节点获得返利百分比",true),
SecondAuthCodeOverdue(9,"second.authCode.overdue","10","验证码过期时间-单位为分钟",true),
UserCountIncrement(10,"count.user.increment","0","用户数量增长记录",false),
ProductPeriodIncrement(11,"count.product.period.increment","0","全站商品期号数量增长记录",false),
;

public void setValue(int value) {
this.value = value;
}

public void setCode(String code) {
this.code = code;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public void setDescription(String description) {
this.description = description;
}
public void setManual(Boolean manual) {
this.manual = manual;
}




private int value;//值
private String code;//唯一编码
private String defaultValue;//默认值
private String description;//描述
private Boolean manual;//是否可以手动设置


ConfigType(int value, String code,String defaultValue, String description, Boolean manual) {
this.value = value;
this.code = code;
this.defaultValue = defaultValue;
this.description = description;
this.manual = manual;
}


public String getCode() {
return code;
}
public int getValue() {
return this.value;
}
public String getDefaultValue() {
return defaultValue;
}


public String getDescription() {
return this.description;
}
public Boolean getManual() {
return manual;
}

}


  public  String getEnumDescript(int value){
ConfigType [] stas = ConfigType .class.getEnumConstants();
for(ConfigType sta: stas){
if(sta.getValue() == value){
return sta.getDescription();
}
}
return "其他";
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值