zoukankan      html  css  js  c++  java
  • java中定义enum示例

    /**
     * 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;
            }
        }
    
    }
  • 相关阅读:
    openssh的服务端配置文件
    SSH的端口转发
    ssh服务
    文件引入
    数据类型的转换
    作用域
    静态变量
    函数
    php嵌入html的解析过程
    PHP执行过程
  • 原文地址:https://www.cnblogs.com/nizuimeiabc1/p/9619719.html
Copyright © 2011-2022 走看看