java中定义enum示例
2024-08-27 15:11:07
/**
* Enumeration for the message delivery mode. Can be persistent or
* non persistent. Use the method 'toInt' to get the appropriate value
* that is used the he AMQP protocol instead of the ordinal() value when
* passing into AMQP APIs.
*
* @author Mark Pollack
* @author Gary Russell
*
*/
public enum MessageDeliveryMode { NON_PERSISTENT, PERSISTENT; public static int toInt(MessageDeliveryMode mode) {
switch (mode) {
case NON_PERSISTENT:
return 1;
case PERSISTENT:
return 2;
default:
return -1;
}
} public static MessageDeliveryMode fromInt(int modeAsNumber) {
switch (modeAsNumber) {
case 1:
return NON_PERSISTENT;
case 2:
return PERSISTENT;
default:
return null;
}
} }
最新文章
- python基础之数据类型(一)
- <;<;<; html图片背景平铺
- [转]jQuery EasyUI自定义DataGrid的Editor
- HDU1568
- linux杂谈
- 如何取消IE“已限制此网页运行可以访问计算机的脚本或ActiveX控件
- GameObject类及相关API
- DAY3-“忙里偷闲”找你玩耍2018-1-11
- JavaScript 递归
- jQuery元素操作
- MySQL导入导出实践
- MySQL图形化管理工具
- java中获取两个时间中的每一天
- Software Testing 2 —— Fault、error and failure小练习
- 超详细从零记录Hadoop2.7.3完全分布式集群部署过程
- Spring MVC controller返回值类型
- Netty之解决TCP粘包拆包(自定义协议)
- 1.cassandra的搭建
- Apache+php+mysql环境配置
- throws 与 throw