Adding some more traces for better debuggability
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / topology / TopoEdgeUpdate.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.sal.topology;
10
11 import java.util.Set;
12
13 import org.opendaylight.controller.sal.core.Edge;
14 import org.opendaylight.controller.sal.core.Property;
15 import org.opendaylight.controller.sal.core.UpdateType;
16
17 /**
18  * The class represents an Edge, the Edge's Property Set and its UpdateType.
19  */
20 public class TopoEdgeUpdate {
21     private Edge edge;
22     private Set<Property> props;
23     private UpdateType type;
24     private boolean isLocal;
25
26     /**
27      * Constructor for a topology element update. A TopologyElementUpdate is an
28      * object that summarize what has happened on an Edge and if the update is
29      * generated locally to this controller or no
30      *
31      * @param e
32      *            Edge being updated
33      * @param p
34      *            Set of Properties attached to the edge
35      * @param t
36      *            Type of update
37      */
38     public TopoEdgeUpdate(Edge e, Set<Property> p, UpdateType t) {
39         edge = e;
40         props = p;
41         type = t;
42         setLocal(true);
43     }
44
45     public Edge getEdge() {
46         return edge;
47     }
48
49     public Set<Property> getProperty() {
50         return props;
51     }
52
53     public UpdateType getUpdateType() {
54         return type;
55     }
56
57     @Override
58     public int hashCode() {
59         final int prime = 31;
60         int result = 1;
61         result = (prime * result) + ((edge == null) ? 0 : edge.hashCode());
62         result = (prime * result) + ((type == null) ? 0 : type.hashCode());
63         return result;
64     }
65
66     @Override
67     public String toString() {
68         return "TopoEdgeUpdate [edge=" + edge + ", props=" + props + ", type=" + type + ", isLocal=" + isLocal + "]";
69     }
70
71     @Override
72     public boolean equals(Object obj) {
73         if (this == obj) {
74             return true;
75         }
76         if (obj == null) {
77             return false;
78         }
79         if (getClass() != obj.getClass()) {
80             return false;
81         }
82         TopoEdgeUpdate other = (TopoEdgeUpdate) obj;
83         if (edge == null) {
84             if (other.edge != null) {
85                 return false;
86             }
87         } else if (!edge.equals(other.edge)) {
88             return false;
89         }
90         if (type != other.type) {
91             return false;
92         }
93         return true;
94     }
95
96     public boolean isLocal() {
97         return isLocal;
98     }
99
100     public void setLocal(boolean isLocal) {
101         this.isLocal = isLocal;
102     }
103 }