Clean all unused and redundant imports in controller.
[controller.git] / opendaylight / arphandler / src / main / java / org / opendaylight / controller / arphandler / ARPRequest.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.arphandler;
11
12 import java.net.InetAddress;
13
14 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
15 import org.opendaylight.controller.switchmanager.Subnet;
16 /*
17  * ARP Request event wrapper Consists of IP and Subnet (and a
18  * HostNodeConnector if is unicast) For unicast request, construct with a
19  * specified host
20  */
21 public class ARPRequest extends ARPEvent {
22     private final Subnet subnet;
23     private final HostNodeConnector host;
24
25     @Override
26     public int hashCode() {
27         final int prime = 31;
28         int result = super.hashCode();
29         result = prime * result + ((host == null) ? 0 : host.hashCode());
30         result = prime * result + ((subnet == null) ? 0 : subnet.hashCode());
31         return result;
32     }
33
34     @Override
35     public boolean equals(Object obj) {
36         if (this == obj) {
37             return true;
38         }
39         if (obj == null) {
40             return false;
41         }
42         if (!(obj instanceof ARPRequest)) {
43             return false;
44         }
45         ARPRequest other = (ARPRequest) obj;
46         if (host == null) {
47             if (other.host != null) {
48                 return false;
49             }
50         } else if (!host.equals(other.host)) {
51             return false;
52         }
53         if (subnet == null) {
54             if (other.subnet != null) {
55                 return false;
56             }
57         } else if (!subnet.equals(other.subnet)) {
58             return false;
59         }
60         return true;
61     }
62
63     // broadcast
64     public ARPRequest(InetAddress ip, Subnet subnet) {
65         super(ip);
66         this.subnet = subnet;
67         this.host = null;
68     }
69
70     // unicast
71     public ARPRequest(HostNodeConnector host, Subnet subnet) {
72         super(host.getNetworkAddress());
73         this.host = host;
74         this.subnet = subnet;
75     }
76
77     public Subnet getSubnet() {
78         return subnet;
79     }
80
81     public HostNodeConnector getHost() {
82         return host;
83     }
84
85     /*
86      * (non-Javadoc)
87      *
88      * @see java.lang.Object#toString()
89      */
90     @Override
91     public String toString() {
92         StringBuilder builder = new StringBuilder();
93         builder.append("ARPRequest [");
94         if (subnet != null) {
95             builder.append("subnet=")
96                     .append(subnet)
97                     .append(", ");
98         }
99         if (host != null) {
100             builder.append("host=")
101                     .append(host);
102         }
103         builder.append("]");
104         return builder.toString();
105     }
106 }