/**
*    Copyright 2011, Big Switch Networks, Inc. 
*    Originally created by David Erickson, Stanford University
* 
*    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 net.floodlightcontroller.linkdiscovery;

import net.floodlightcontroller.core.IOFSwitch;

/**
 * @author David Erickson (daviderickson@cs.stanford.edu)
 *
 */
public class SwitchPortTuple {
    protected IOFSwitch sw;
    protected Short port;

    public SwitchPortTuple(IOFSwitch sw, Short port) {
        super();
        this.sw = sw;
        this.port = port;
    }

    /**
     * Convenience constructor, port is immediately cast to a short
     * @param id
     * @param port
     */
    public SwitchPortTuple(IOFSwitch sw, Integer port) {
        this(sw, port.shortValue());
    }

    /**
     * @return the sw
     */
    public IOFSwitch getSw() {
        return sw;
    }

    /**
     * Set the switch
     */
    public void setSw(IOFSwitch sw) {
        this.sw = sw;
    }
    
    /**
     * @return the port number
     */
    public Short getPort() {
        return port;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 5557;
        int result = 1;
        result = prime * result + ((sw == null) ? 0 : sw.hashCode());
        result = prime * result + ((port == null) ? 0 : port.hashCode());
        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 (!(obj instanceof SwitchPortTuple))
            return false;
        SwitchPortTuple other = (SwitchPortTuple) obj;
        if (sw == null) {
            if (other.sw != null)
                return false;
        } else if (!sw.equals(other.sw))
            return false;
        
        if (port == null) {
            if (other.port != null)
                return false;
        } else if (!port.equals(other.port))
            return false;

        return true;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "SwitchPortTuple [id="
                + ((sw == null) ? "null" : sw.getStringId())
                + ", port=" + ((port == null) ? "null" : (0xff & port)) + "]";
    }
}

@@ -939,17 +939,17 @@
 otected 
-S
+s
 hort por
@@ -993,17 +993,17 @@
 tch sw, 
-S
+s
 hort por
@@ -1082,128 +1082,12 @@
   %7D%0A
-%0A
     
-/**%0A     * Convenience constructor, port is immediately cast to a short%0A     * @param id%0A     * @param port%0A     */
 %0A   
@@ -1128,15 +1128,11 @@
 sw, 
-I
+i
 nt
-eger
  por
@@ -1157,25 +1157,19 @@
 sw, 
-port.shortValue()
+(short)port
 );%0A 
@@ -1758,33 +1758,24 @@
  + (
-(port == null) ? 0 : 
+new Short(
 port
+))
 .has
@@ -1773,33 +1773,32 @@
 ort)).hashCode()
-)
 ;%0A        return
@@ -2366,117 +2366,11 @@
 ort 
-== null) %7B%0A            if (other.port != null)%0A                return false;%0A        %7D else if (!port.equals(
+!= 
 othe
@@ -2376,17 +2376,16 @@
 er.port)
-)
 %0A       
@@ -2678,50 +2678,29 @@
 =%22 +
- ((port == null) ? %22null%22 :
  (0xff
+ff
  & 
+(int)
 port)
-)
  + %22

Change type of port from Short to short and fix toString.