---
title: "枚举例子"
author: "rainyear"
date: "2011-12-22T17:24:30Z"
tags: []
categories: ["非技术"]
slug: "untitled"
draft: false
lastmod: "2012-03-01T16:34:29Z"
id: 1321037
url: "https://rainyear.iteye.com/blog/1321037"
---

public enum PCOptionStatusEnum {
		WAITTING_HANDLING("0", "待处理"), HANDLE_SUCCESS("1", "处理成功"), HANDLE_FAILUER("2", "处理失败"), HANDLE_CANCEL("3",
				"作废"), HANDLING("4", "处理中");
		private final String key;

		private final String value;

		PCOptionStatusEnum(String key, String value) {
			this.key = key;
			this.value = value;
		}

		public String getKey() {
			return key;
		}

		public String getValue() {
			return value;
		}

		public static Map<String, String> getList() {
			Map<String, String> map = new HashMap<String, String>();

			for (PCOptionStatusEnum w : PCOptionStatusEnum.values()) {
				map.put(w.getKey(), w.getValue());
			}
			return map;
		}


public class StatusEnum implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6806619642573481280L;
	
	/**
	 * 订单来源类型
	 * 
	 * @author zhaowei 
	 * 2011-12-16 add
	 * 
	 */
	public enum OrderTypeEnum {
		TB_ORDER("B", "宝"), ZF_ORDER("F", "发"), CFT_ORDER("FT", "付通");
		private OrderTypeEnum(String key, String value) {
			this.key = key;
			this.value = value;
		}

		private final String key;
		private final String value;

		public String getKey() {
			return key;
		}

		public String getValue() {
			return value;
		}
		
		/**
		 * 获取订单状态
		 * 
		 * @return
		 */
		public static Map<String, String> getOrderTypeList() {
			Map<String, String> status = new HashMap<String, String>();
			status.put("TB", "宝");
			status.put("ZF", "发");
			status.put("CFT", "通");
			return status;

		}

		public static String getReviewStatus(String key) {
			for (OrderStatusEnum status : OrderStatusEnum.values()) {
				if (status.getKey().equals(key)) {
					return status.getValue();
				}
			}
			return "";
		}
	}


	/**

	 * 
	 * @author zhangf
	 * 
	 */
	public enum DrawBillStatusEnum {
		NOT_CHECKED(0, "未"), CHECKED_ING(1, "中"), CHECKED_SUCCESS(2, "通过"), CHECKED_FAIL(3, "通过"), DRAW_FINISHED(
				4, "已"), DRAW_SUCCESS(5, "成功"), DRAW_FAIL(6, "失败"), DRAW_CANCEL(7,"撤");

		private DrawBillStatusEnum(int key, String value) {
			this.key = key;
			this.value = value;
		}

		private final int key;
		private final String value;

		public int getKey() {
			return key;
		}

		public String getValue() {
			return value;
		}

		/**
		 * 根据第一个参数查找第二个参数的值
		 * 
		 * @param p1
		 * @return
		 */

		public static String getP2ByP1(int param1) {
			for (DrawBillStatusEnum w : DrawBillStatusEnum.values()) {
				if (param1 == w.getKey()) {
					return w.getValue();
				}
			}
			return "";
		}

		/**
		 * 将枚举的值的参数以 key：value的形式存入map
		 * 
		 * @return
		 */
		public static Map<String, String> getElemMap() {
			Map<String, String> map = new LinkedHashMap<String, String>();

			for (DrawBillStatusEnum w : DrawBillStatusEnum.values()) {
				map.put(String.valueOf(w.getKey()), w.getValue());
			}
			return map;
		}

	}
}