`
xxpp688
  • 浏览: 13805 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

java枚举小用

    博客分类:
  • java
 
阅读更多
public enum ExportType {

	CSV("csv", ".csv"), EXCEL2003("excel3", ".xls"), EXCEL2007("excel7", ".xlsx"), PDF("pdf", ".pdf"), DBF("dbf", ".dbf"), WORD("word", ".doc"), TXT(
			"txt", ".txt");

	private ExportType() {

	}

	private ExportType(String code, String suffix) {
		this.code = code;
		this.suffix = suffix;
	}

	private String suffix;
	private String code;

	public String getSuffix() {
		return suffix;
	}

	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public static String getExSuffix(String code) {
		if (StringUtils.isNotBlank(code)) {
			for (ExportType c : ExportType.values()) {
				if (StringUtils.equals(c.getCode(), code)) {
					return c.suffix;
				}
			}
		}
		return "";
	}
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics