com.nmote.smpp.AlertNotificationPDU.java Source code

Java tutorial

Introduction

Here is the source code for com.nmote.smpp.AlertNotificationPDU.java

Source

/*
 * Copyright (c) Nmote d.o.o. 2003-2015. All rights reserved.
 * See LICENSE.txt for licensing information.
 */

/*
 * WARNING Do not modify this file.
 *
 * This file was generated from protocol description file
 * and will be OVERWRITTEN on next invocation of
 * smpp-gen ant task during build process.
 */

package com.nmote.smpp;

import java.io.IOException;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;

/**
 * ToBeDocumented
 *
 * @author (this class was autogenerated)
 */
public class AlertNotificationPDU extends AbstractPDU {

    private static final long serialVersionUID = About.SERIAL_VERSION_UID;

    /**
     * Creates a new PDU object.
     */
    public AlertNotificationPDU() {
    }

    /**
     * Returns Command ID for this PDU.
     *
     * @return PDU.ALERT_NOTIFICATION;
     */
    public int getCommandId() {
        return PDU.ALERT_NOTIFICATION;
    }

    /**
     * Reads mandatory and optional parameters from SMPPInputStream.
     *
     * @param in SMPPInputStream for reading parameters.
     * @throws IOException In case of a problem while reading data.
     */
    void readParameters(SMPPInputStream in) throws IOException {
        // Mandatory parameters
        source_addr = in.readSMPPAddress();
        esme_addr = in.readSMPPAddress();

        // Optional parameters
        readOptionalParameters(in);
    }

    /**
     * Write mandatory and optional PDU parameters to SMPPOutputStream.
     *
     * @param out SMPPOutputStream for writting paramters.
     * @throws IOException In case of errors while writing.
     */
    void writeParameters(SMPPOutputStream out) throws IOException {
        // Mandatory parameters
        out.writeSMPPAddress(source_addr);
        out.writeSMPPAddress(esme_addr);

        // Optional parameters
        writeOptionalParameters(out);
    }

    /**
     * @see com.nmote.smpp.AbstractPDU#isRequestPDU()
     */
    public boolean isRequestPDU() {
        return true;
    }

    /**
     * @see com.nmote.smpp.AbstractPDU#createResponse()
     */
    public AbstractPDU createResponse() {
        return null;
    }

    /**
     * @see com.nmote.smpp.AbstractPDU#isOneWay()
     */
    public final boolean isOneWay() {
        return true;
    }

    /**
     * Returns PDU name.
     *
     * @return PDU name
     */
    public String getName() {
        return "alert_notification";
    }

    /**
     * Creates a string representation of a PDU.
     *
     * @return a String
     */
    public String toString() {
        ToStringBuilder b = new ToStringBuilder(this);
        b.append(getSequence());
        b.append(ESMEStatus.toString(getStatus()));

        // Appending mandatory parameters
        b.append("source_addr", toStringHelper(source_addr));
        b.append("esme_addr", toStringHelper(esme_addr));

        // Appending optional parameters
        if (getParameters() != null) {
            b.append(getParameters());
        }

        return b.toString();
    }

    /**
     * Calculates hash code of this object.
     *
     * @return hash code
     */
    public int hashCode() {
        HashCodeBuilder b = new HashCodeBuilder();
        b.append(getSequence());
        b.append(getStatus());

        // Appending mandatory parameters
        b.append(source_addr);
        b.append(esme_addr);

        // Appending optional parameters
        if (getParameters() != null) {
            b.append(getParameters());
        }

        return b.toHashCode();
    }

    /**
     * Checks if <code>o</code> and this object are equal.
     *
     * @return true if objects are equal, false otherwise
     */
    public boolean equals(Object o) {
        boolean result;
        if (o instanceof AlertNotificationPDU) {
            AlertNotificationPDU p = (AlertNotificationPDU) o;
            EqualsBuilder b = new EqualsBuilder();
            b.append(p.getSequence(), getSequence());
            b.append(p.getStatus(), getStatus());

            // Appending mandatory parameters
            b.append(p.source_addr, source_addr);
            b.append(p.esme_addr, esme_addr);

            // Appending optional parameters
            b.append(p.getParameters(), getParameters());

            result = b.isEquals();
        } else {
            result = false;
        }

        return result;
    }

    // Mandatory parameters

    private SMPPAddress source_addr;

    /**
     * Getter for a mandatory parameter source_addr.
     * 
     * @return parameter value
     */
    public SMPPAddress getSourceAddr() {
        return source_addr;
    }

    /**
     * Setter for a mandatory parameter source_addr.
     * 
     * @param value New parameter value.
     */
    public void setSourceAddr(SMPPAddress value) {
        source_addr = value;
    }

    private SMPPAddress esme_addr;

    /**
     * Getter for a mandatory parameter esme_addr.
     * Specifies the address of an ESME address to which an alert_notification should be routed.
     * @return parameter value
     */
    public SMPPAddress getEsmeAddr() {
        return esme_addr;
    }

    /**
     * Setter for a mandatory parameter esme_addr.
     * Specifies the address of an ESME address to which an alert_notification should be routed.
     * @param value New parameter value.
     */
    public void setEsmeAddr(SMPPAddress value) {
        esme_addr = value;
    }
}