---
title: "java枚举小用"
author: "xxpp688"
date: "2013-07-09T10:58:53Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2013-07-09T10:58:31Z"
id: 1901797
url: "https://xxpp688.iteye.com/blog/1901797"
---

```
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 "";
	}
}
```