Example #1
0
 /**
  * 取枚举的json字符串
  *
  * @return
  */
 public static String getJsonStr() {
   PayTypeEnum[] enums = PayTypeEnum.values();
   StringBuffer jsonStr = new StringBuffer("[");
   for (PayTypeEnum senum : enums) {
     if (!"[".equals(jsonStr.toString())) {
       jsonStr.append(",");
     }
     jsonStr.append("{id:'").append(senum).append("',desc:'").append(senum.getDesc()).append("'}");
   }
   jsonStr.append("]");
   return jsonStr.toString();
 }
Example #2
0
 public static PayTypeEnum getEnum(String name) {
   PayTypeEnum[] arry = PayTypeEnum.values();
   for (int i = 0; i < arry.length; i++) {
     if (arry[i].name().equalsIgnoreCase(name)) {
       return arry[i];
     }
   }
   return null;
 }
Example #3
0
 public static Map<String, Map<String, Object>> toMap() {
   PayTypeEnum[] ary = PayTypeEnum.values();
   Map<String, Map<String, Object>> enumMap = new HashMap<String, Map<String, Object>>();
   for (int num = 0; num < ary.length; num++) {
     Map<String, Object> map = new HashMap<String, Object>();
     String key = ary[num].name();
     map.put("desc", ary[num].getDesc());
     enumMap.put(key, map);
   }
   return enumMap;
 }
Example #4
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 public static List toList() {
   PayTypeEnum[] ary = PayTypeEnum.values();
   List list = new ArrayList();
   for (int i = 0; i < ary.length; i++) {
     Map<String, String> map = new HashMap<String, String>();
     map.put("desc", ary[i].getDesc());
     map.put("name", ary[i].name());
     list.add(map);
   }
   return list;
 }