package net.onrc.onos.apps.sdnip;

import java.net.InetAddress;

import org.codehaus.jackson.annotate.JsonProperty;

import com.google.common.net.InetAddresses;

/**
 * Configuration details for a BGP peer. It contains the peer's IP address and
 * an interface name which maps to the interface they are attached at.
 */
public class BgpPeer {
    private final String interfaceName;
    private final InetAddress ipAddress;

    /**
     * Class constructor, taking the interface name and IP address of the peer.
     *
     * @param interfaceName the String name of the interface which can be used
     * to look up the interface this peer is attached at
     * @param ipAddress the IP address of the peer as a String
     */
    public BgpPeer(@JsonProperty("interface") String interfaceName,
                   @JsonProperty("ipAddress") String ipAddress) {
        this.interfaceName = interfaceName;
        this.ipAddress = InetAddresses.forString(ipAddress);
    }

    /**
     * Gets the interface name.
     *
     * @return the interface name as a String
     */
    public String getInterfaceName() {
        return interfaceName;
    }

    /**
     * Gets the IP address of the peer.
     *
     * @return the IP address as an {@link InetAddress} object
     */
    public InetAddress getIpAddress() {
        return ipAddress;
    }
}

@@ -56,16 +56,42 @@
 Address;
+%0Aimport java.util.Objects;
 %0A%0Aimport
@@ -1366,11 +1366,492 @@
 s;%0A    %7D
+%0A%0A    @Override%0A    public int hashCode() %7B%0A        return Objects.hash(interfaceName, ipAddress);%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object obj) %7B%0A        if (obj == this) %7B%0A            return true;%0A        %7D%0A%0A        if (!(obj instanceof BgpPeer)) %7B%0A            return false;%0A        %7D%0A%0A        BgpPeer that = (BgpPeer) obj;%0A        return Objects.equals(this.interfaceName, that.interfaceName)%0A                && Objects.equals(this.ipAddress, that.ipAddress);%0A    %7D
 %0A%7D%0A

Implement missing equals() and hashCode() in BgpPeer