Merge "Implemented ordering of yang module data nodes. Added Comparators utility...
[controller.git] / opendaylight / samples / simpleforwarding / src / main / java / org / opendaylight / controller / samples / simpleforwarding / HostNodePair.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.samples.simpleforwarding;
11
12 import java.io.Serializable;
13
14 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
15 import org.opendaylight.controller.sal.core.Node;
16
17 /**
18  * Class that represent a pair of {Host, Node}, the intent of it
19  * is to be used as a key in the database kept by IPSwitching module
20  * where for every Host, Switch we will have a Forwarding Rule that
21  * will route the traffic toward the /32 destination
22  *
23  */
24 public class HostNodePair implements Serializable {
25     private static final long serialVersionUID = 1L;
26     private HostNodeConnector host;
27     private Node node;
28
29     public HostNodePair(HostNodeConnector h, Node s) {
30         setNode(s);
31         setHost(h);
32     }
33
34     public Node getNode() {
35         return node;
36     }
37
38     public void setNode(Node nodeId) {
39         this.node = nodeId;
40     }
41
42     public HostNodeConnector getHost() {
43         return host;
44     }
45
46     public void setHost(HostNodeConnector host) {
47         this.host = host;
48     }
49
50     @Override
51     public int hashCode() {
52         final int prime = 31;
53         int result = 1;
54         result = prime * result + ((host == null) ? 0 : host.hashCode());
55         result = prime * result + ((node == null) ? 0 : node.hashCode());
56         return result;
57     }
58
59     @Override
60     public boolean equals(Object obj) {
61         if (this == obj)
62             return true;
63         if (obj == null)
64             return false;
65         if (getClass() != obj.getClass())
66             return false;
67         HostNodePair other = (HostNodePair) obj;
68         if (host == null) {
69             if (other.host != null)
70                 return false;
71         } else if (!host.equals(other.host))
72             return false;
73         if (node == null) {
74             if (other.node != null)
75                 return false;
76         } else if (!node.equals(other.node))
77             return false;
78         return true;
79     }
80
81     @Override
82     public String toString() {
83         return "HostNodePair [host=" + host + ", node=" + node + "]";
84     }
85 }