|
|
@@ -193,6 +193,22 @@ public enum CreditTypeEnum {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public static CreditTypeEnum fromNameOrCode(String nameOrCode) {
|
|
|
+ for (CreditTypeEnum item : CreditTypeEnum.values()) {
|
|
|
+ if (item.name().equals(nameOrCode)) {
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer code = Integer.valueOf(nameOrCode);
|
|
|
+
|
|
|
+ for (CreditTypeEnum item : CreditTypeEnum.values()) {
|
|
|
+ if (item.code().equals(code)) {
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
return this.name();
|
|
|
@@ -202,12 +218,17 @@ public enum CreditTypeEnum {
|
|
|
* 校验重复的code值
|
|
|
*/
|
|
|
public static void main(String[] args) {
|
|
|
- CreditTypeEnum[] thisEnums = CreditTypeEnum.values();
|
|
|
+ /*CreditTypeEnum[] thisEnums = CreditTypeEnum.values();
|
|
|
List<Integer> codeList = new ArrayList<>();
|
|
|
for (CreditTypeEnum thisEnum : thisEnums) {
|
|
|
if (!codeList.contains(thisEnum.code)) {
|
|
|
codeList.add(thisEnum.code());
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ CreditTypeEnum term_consume = fromNameOrCode("TERM_CONSUME");
|
|
|
+ System.err.println(term_consume);
|
|
|
+ CreditTypeEnum creditTypeEnum = fromNameOrCode("25000");
|
|
|
+ System.err.println(creditTypeEnum);
|
|
|
+
|
|
|
}
|
|
|
}
|