package com.mx.enums;
import com.exigen.ipb.base.util.ResourceBundleUtils;
import java.util.ResourceBundle;
public enum CustomerRole {
SELF("SELF"),
SPOUSE("SPOUSE"),
CHILD("CHILD"),
PARENT("PARENT"),
FRIEND("FRIEND"),
OTHER("OTHER"),
Self("Self"),
Spouse("Spouse/Domestic Partner"),
Child("Dependent Child"),
Trust("Trust/Charity"),
Other("Other"),
DISABLED_DEPENDENT("DISABLED_DEPENDENT"),
Disabled_Dependent("Disabled Dependent");
private static final String BUNDLE = "com/../../..";//your file relative path(note:don not attach '.properties' suffix)
private String value;
private CustomerRole(String value) {
this.value = value;
}
public String getValue() {
ResourceBundle bundel = ResourceBundle.getBundle(BUNDLE);
// this.name()就是enum的名字,value即为name所对应的的value
return ResourceBundleUtils.getString(bundel, this.name(), this.value);
}
}
propertie文件:
SELF=SELF
SPOUSE=SPOUSE
CHILD=CHILD
PARENT=PARENT
FRIEND=FRIEND
OTHER=OTHER
DISABLED_DEPENDENT=DISABLED_DEPENDENT
Self=Self
Spouse=Spouse/Domestic Partner
Child=Dependent Child
Trust=Trust/Charity
Other=Other
Disabled_Dependent=Disabled Dependent