fff46eafaf99ba48b96d5d5093ad4102daa5bb23
[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.apache.commons.lang3.builder.ReflectionToStringBuilder;
14 import org.opendaylight.controller.sal.core.Edge;
15 import org.opendaylight.controller.sal.core.Property;
16 import org.opendaylight.controller.sal.core.UpdateType;
17
18 /**
19  * The class represents an Edge, the Edge's Property Set and its UpdateType.
20  */
21
22 public class TopoEdgeUpdate {
23     private Edge edge;
24     private Set<Property> props;
25     private UpdateType type;
26
27     public TopoEdgeUpdate(Edge e, Set<Property> p, UpdateType t) {
28         edge = e;
29         props = p;
30         type = t;
31     }
32
33     public Edge getEdge() {
34         return edge;
35     }
36
37     public Set<Property> getProperty() {
38         return props;
39     }
40
41     public UpdateType getUpdateType() {
42         return type;
43     }
44
45     @Override
46     public int hashCode() {
47         final int prime = 31;
48         int result = 1;
49         result = prime * result + ((edge == null) ? 0 : edge.hashCode());
50         result = prime * result + ((props == null) ? 0 : props.hashCode());
51         result = prime * result + ((type == null) ? 0 : type.hashCode());
52         return result;
53     }
54
55     @Override
56     public String toString() {
57         return "TopoEdgeUpdate[" + ReflectionToStringBuilder.toString(this)
58                 + "]";
59     }
60
61     @Override
62     public boolean equals(Object obj) {
63         if (this == obj)
64             return true;
65         if (obj == null)
66             return false;
67         if (getClass() != obj.getClass())
68             return false;
69         TopoEdgeUpdate other = (TopoEdgeUpdate) obj;
70         if (edge == null) {
71             if (other.edge != null)
72                 return false;
73         } else if (!edge.equals(other.edge))
74             return false;
75         if (props == null) {
76             if (other.props != null)
77                 return false;
78         } else if (!props.equals(other.props))
79             return false;
80         if (type != other.type)
81             return false;
82         return true;
83     }
84 }