Merge "BUG-2218: Keep existing link augmentations during discovery process"
[controller.git] / opendaylight / adsal / 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  * If update is on new properties added to an existing edge, appropriate type is CHANGED.
20  */
21 public class TopoEdgeUpdate {
22     private Edge edge;
23     private Set<Property> props;
24     private UpdateType type;
25     private boolean isLocal;
26
27     /**
28      * Constructor for a topology element update. A TopologyElementUpdate is an
29      * object that summarize what has happened on an Edge and if the update is
30      * generated locally to this controller or no
31      *
32      * @param e
33      *            Edge being updated
34      * @param p
35      *            Set of Properties attached to the edge
36      * @param t
37      *            Type of update
38      */
39     public TopoEdgeUpdate(Edge e, Set<Property> p, UpdateType t) {
40         edge = e;
41         props = p;
42         type = t;
43         setLocal(true);
44     }
45
46     public Edge getEdge() {
47         return edge;
48     }
49
50     public Set<Property> getProperty() {
51         return props;
52     }
53
54     public UpdateType getUpdateType() {
55         return type;
56     }
57
58     @Override
59     public int hashCode() {
60         final int prime = 31;
61         int result = 1;
62         result = (prime * result) + ((edge == null) ? 0 : edge.hashCode());
63         result = (prime * result) + ((type == null) ? 0 : type.hashCode());
64         return result;
65     }
66
67     @Override
68     public String toString() {
69         return "TopoEdgeUpdate [edge=" + edge + ", props=" + props + ", type=" + type + ", isLocal=" + isLocal + "]";
70     }
71
72     @Override
73     public boolean equals(Object obj) {
74         if (this == obj) {
75             return true;
76         }
77         if (obj == null) {
78             return false;
79         }
80         if (getClass() != obj.getClass()) {
81             return false;
82         }
83         TopoEdgeUpdate other = (TopoEdgeUpdate) obj;
84         if (edge == null) {
85             if (other.edge != null) {
86                 return false;
87             }
88         } else if (!edge.equals(other.edge)) {
89             return false;
90         }
91         if (type != other.type) {
92             return false;
93         }
94         return true;
95     }
96
97     public boolean isLocal() {
98         return isLocal;
99     }
100
101     public void setLocal(boolean isLocal) {
102         this.isLocal = isLocal;
103     }
104 }