blob: 37626fe6629a6f82c05570bb2532184d61d5c665 [file] [log] [blame]
Satish Kf6d87cb2015-11-30 19:59:22 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Satish Kf6d87cb2015-11-30 19:59:22 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
18 * Implementation of RouteDistinguisher.
19 */
20package org.onosproject.iptopology.api;
21
22import static com.google.common.base.MoreObjects.toStringHelper;
23
24import java.util.Objects;
25
26/**
27 * Represents Route Distinguisher of device in the network.
28 */
29public class RouteDistinguisher {
30 private final Long routeDistinguisher;
31
32 /**
33 * Constructor to initialize parameters.
34 *
35 * @param routeDistinguisher route distinguisher
36 */
37 public RouteDistinguisher(Long routeDistinguisher) {
38 this.routeDistinguisher = routeDistinguisher;
39 }
40
41 /**
42 * Obtain route distinguisher.
43 *
44 * @return route distinguisher
45 */
46 public Long routeDistinguisher() {
47 return routeDistinguisher;
48 }
49
50 @Override
51 public int hashCode() {
52 return Objects.hash(routeDistinguisher);
53 }
54
55 @Override
56 public boolean equals(Object obj) {
57 if (this == obj) {
58 return true;
59 }
60
61 if (obj instanceof RouteDistinguisher) {
62 RouteDistinguisher other = (RouteDistinguisher) obj;
63 return Objects.equals(routeDistinguisher, other.routeDistinguisher);
64 }
65 return false;
66 }
67
68 @Override
69 public String toString() {
70 return toStringHelper(this)
71 .add("routeDistinguisher", routeDistinguisher)
72 .toString();
73 }
74}