⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bindtype.java

📁 JSMPP Examples to send and receive sms from java via smpp protocol.
💻 JAVA
字号:
/*
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package org.jsmpp.bean;

import org.jsmpp.SMPPConstant;

/**
 * Enum represent bind type of SMPP. There is 3 bind type provide by SMPP:
 * <ul>
 * <li>receiver (BIND_RX) - receive only</li>
 * <li>transmitter (BIND_TX) - transmit only</li>
 * <li>transceiver (BIND_TRX) - receive and transmit</li>
 * </ul>
 * 
 * @author uudashr
 * @version 1.0
 * @since 1.0
 * 
 */
public enum BindType {

    /**
     * Bind transmitter.
     */
    BIND_TX(SMPPConstant.CID_BIND_TRANSMITTER),

    /**
     * Bind receiver.
     */
    BIND_RX(SMPPConstant.CID_BIND_RECEIVER),

    /**
     * Bind transceiver.
     */
    BIND_TRX(SMPPConstant.CID_BIND_TRANSCEIVER);

    private int bindCommandId;

    private BindType(int bindCommadId) {
        this.bindCommandId = bindCommadId;
    }

    /**
     * Get the command_id of given bind type.
     * 
     * @return the bind command_id.
     */
    public int commandId() {
        return bindCommandId;
    }

    /**
     * Return the response command_id that should given by this bind type.
     * 
     * @return the bind response command_id.
     */
    public int responseCommandId() {
        return bindCommandId | SMPPConstant.MASK_CID_RESP;
    }

    /**
     * Inform whether the bind type is transmitable.
     * 
     * @return <tt>true</tt> f the bind type is transmitable, otherwise
     *         <tt>false</tt>.
     */
    public boolean isTransmitable() {
        return this == BIND_TX || this == BIND_TRX;
    }

    /**
     * Inform whether the bind type is receivable.
     * 
     * @return <tt>true</tt> if the bind type is receivable, otherwise
     *         <tt>false</tt>.
     */
    public boolean isReceiveable() {
        return this == BIND_RX || this == BIND_TRX;
    }

    /**
     * Get the <tt>BindType</tt> by specified command_id.
     * 
     * @param bindCommandId is the command_id.
     * @return the enum const associated with the specified
     *         <tt>bindCommandId</tt>.
     * @throws IllegalArgumentException if there is no <tt>BindType</tt>
     *         associated with specified <tt>bindCommandId</tt> found.
     */
    public static final BindType valueOf(int bindCommandId)
            throws IllegalArgumentException {
        for (BindType bindType : values()) {
            if (bindType.bindCommandId == bindCommandId) {
                return bindType;
            }
        }
        throw new IllegalArgumentException(
                "No enum const BindType with command id " + bindCommandId);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -