枚举工具类until
Posted caixiaoyou
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了枚举工具类until相关的知识,希望对你有一定的参考价值。
1 public enum RMB { 2 3 4 YIBAI(100,"一百"), 5 WUSHI(50,"五十"), 6 SHIKUAI(10,"十块"), 7 WUKUAI(5,"五块"), 8 YIYUAN(1,"一元"); 9 10 private int code; 11 private String name; 12 13 private RMB(int code, String name) { 14 this.code = code; 15 this.name = name; 16 } 17 18 19 public int getCode() { 20 return code; 21 } 22 23 public void setCode(int code) { 24 this.code = code; 25 } 26 27 public String getName() { 28 return name; 29 } 30 31 public void setName(String name) { 32 this.name = name; 33 } 34 35 @Override 36 public String toString() { 37 return "RMB{" + 38 "code=‘" + code + ‘‘‘ + 39 ", name=‘" + name + ‘‘‘ + 40 ‘}‘; 41 } 42 43 public static String getRMBName(int code) { 44 for(RMB rmbEnum: RMB.values()) { 45 if(rmbEnum.getCode() == code) 46 return rmbEnum.name; 47 } 48 return null; 49 } 50 51 public static RMB getRMBByCode(int code){ 52 switch (code) { 53 case 1: 54 return YIYUAN; 55 case 5: 56 return WUKUAI; 57 case 10: 58 return SHIKUAI; 59 case 50: 60 return WUSHI; 61 case 100: 62 return YIBAI; 63 default: 64 return null; 65 } 66 } 67 68 }
自用until
以上是关于枚举工具类until的主要内容,如果未能解决你的问题,请参考以下文章
elasticsearch代码片段,及工具类SearchEsUtil.java