/*
 * 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 java.io.Serializable;

import org.jsmpp.util.IntUtil;

/**
 * Class represent SMPP Command. Contains only the header of SMPP PDU.
 * 
 * @author uudashr
 * @version 1.0
 * 
 */
public class Command implements Serializable {
    private static final long serialVersionUID = -5226111982905878489L;
    
    protected int commandLength;
    protected int commandId;
    protected int commandStatus;
    protected int sequenceNumber;

    /**
     * Default constructor.
     */
    public Command() {

    }

    /**
     * Get the command_id.
     * 
     * @return the command_id.
     */
    public int getCommandId() {
        return commandId;
    }

    /**
     * Get the command_id as hex string value.
     * 
     * @return the hex string value of command_id.
     */
    public String getCommandIdAsHex() {
        return IntUtil.toHexString(commandId);
    }

    /**
     * Set the command_id.
     * 
     * @param commandId is the new value of command_id..
     */
    public void setCommandId(int commandId) {
        this.commandId = commandId;
    }

    /**
     * Get the command_length.
     * 
     * @return the command_length.
     */
    public int getCommandLength() {
        return commandLength;
    }

    /**
     * Ser the command_length.
     * 
     * @param commandLength is the new value of command_length.
     */
    public void setCommandLength(int commandLength) {
        this.commandLength = commandLength;
    }

    /**
     * Get the command_status.
     * 
     * @return the command_status.
     */
    public int getCommandStatus() {
        return commandStatus;
    }

    /**
     * Get the command_status as hex string.
     * 
     * @return the hex string value of command_status.
     */
    public String getCommandStatusAsHex() {
        return IntUtil.toHexString(commandStatus);
    }

    /**
     * Set value of command_status.
     * 
     * @param commandStatus is the new value of command_status.
     */
    public void setCommandStatus(int commandStatus) {
        this.commandStatus = commandStatus;
    }

    /**
     * Get the sequence_number.
     * 
     * @return the value of sequence_number.
     */
    public int getSequenceNumber() {
        return sequenceNumber;
    }

    /**
     * Set value of sequence_number.
     * 
     * @param sequenceNumber is the new value of sequece_number.
     */
    public void setSequenceNumber(int sequenceNumber) {
        this.sequenceNumber = sequenceNumber;
    }
    
    @Override
    public String toString() {
        return "PDUHeader(" + commandLength + ", " + getCommandIdAsHex() + ", " + getCommandStatusAsHex() + ", " + sequenceNumber + ")";
    }
    
    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int PRIME = 31;
        int result = 1;
        result = PRIME * result + commandId;
        result = PRIME * result + commandLength;
        result = PRIME * result + commandStatus;
        result = PRIME * result + sequenceNumber;
        return result;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        final Command other = (Command)obj;
        if (commandId != other.commandId)
            return false;
        if (commandLength != other.commandLength)
            return false;
        if (commandStatus != other.commandStatus)
            return false;
        if (sequenceNumber != other.sequenceNumber)
            return false;
        return true;
    }
    
}

@@ -62,17 +62,16 @@
 cense%22);
- 
 %0A * you 
@@ -130,17 +130,16 @@
 License.
- 
 %0A * You 
@@ -176,17 +176,16 @@
 se at%0A *
- 
 %0A *    h
@@ -228,17 +228,16 @@
 E-2.0%0A *
- 
 %0A * Unle
@@ -552,17 +552,16 @@
 ense.%0A *
- 
 %0A */%0Apac
@@ -610,16 +610,42 @@
 lizable;
+%0Aimport java.util.Objects;
 %0A%0Aimport
@@ -1861,17 +1861,17 @@
     * Se
-r
+t
  the com
@@ -2969,16 +2969,17 @@
 of seque
+n
 ce_numbe
@@ -3433,268 +3433,84 @@
     
-final int PRIME = 31;%0A        int result = 1;%0A        result = PRIME * result + commandId;%0A        result = PRIME * result + commandLength;%0A        result = PRIME * result + commandStatus;%0A        result = PRIME * result + sequenceNumber;%0A        return result
+return Objects.hash(commandLength, commandId, commandStatus, sequenceNumber)
 ;%0A  
@@ -3660,18 +3660,16 @@
 Object o
-bj
 ) %7B%0A    
@@ -3685,18 +3685,16 @@
 his == o
-bj
 )%0A      
@@ -3728,20 +3728,34 @@
 if (
-obj == null)
+!(o instanceof Command)) %7B
 %0A   
@@ -3789,163 +3789,63 @@
     
-if (getClass() != obj.getClass())%0A            return false;%0A        final Command other = (Command)obj;%0A        if (c
+%7D%0A        final Command command = (C
 ommand
-Id != other.commandId)%0A 
+) o;%0A
         
    r
@@ -3844,37 +3844,15 @@
     
-   
 return 
-false;%0A        if (
 comm
@@ -3861,24 +3861,26 @@
 dLength 
-!= other
+== command
 .command
@@ -3889,48 +3889,46 @@
 ngth
-)%0A            return false;%0A        if (
+ && commandId == command.commandId && 
 comm
@@ -3937,24 +3937,26 @@
 dStatus 
-!= other
+== command
 .command
@@ -3965,48 +3965,12 @@
 atus
-)%0A            return false;%0A        if (
+ && 
 sequ
@@ -3984,16 +3984,18 @@
 ber 
-!= other
+== command
 .seq
@@ -4009,55 +4009,8 @@
 mber
-)%0A            return false;%0A        return true
 ;%0A  

Use Objects for hash and fix some typos.