blob: ca217b6495996656d6e2121b3d956e612562d19f [file] [log] [blame]
Mohammad Shahidaa7c1232017-08-09 11:13:15 +05301/*
2 * Copyright 2017-present Open Networking Foundation
3 *
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
Ray Milkeya95193c2017-08-10 15:35:36 -070017package org.onosproject.evpnrouteservice;
Mohammad Shahidaa7c1232017-08-09 11:13:15 +053018
19import java.util.Objects;
20
21import static com.google.common.base.MoreObjects.toStringHelper;
22import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
25 * Represents Route Distinguisher of device in the network.
26 */
27public final class RouteDistinguisher {
28 private final String routeDistinguisher;
29
30 /**
31 * Constructor to initialize parameters.
32 *
33 * @param routeDistinguisher route distinguisher
34 */
35 private RouteDistinguisher(String routeDistinguisher) {
36 this.routeDistinguisher = routeDistinguisher;
37 }
38
39 /**
40 * Creates the route distinguisher.
41 *
42 * @param routeDistinguisher route distinguisher
43 * @return RouteDistinguisher
44 */
45 public static RouteDistinguisher routeDistinguisher(String routeDistinguisher) {
46 checkNotNull(routeDistinguisher);
47 return new RouteDistinguisher(routeDistinguisher);
48 }
49
50 /**
51 * get route distinguisher.
52 *
53 * @return distinguisher
54 */
55 public String getRouteDistinguisher() {
56 return routeDistinguisher;
57 }
58
59 @Override
60 public int hashCode() {
61 return Objects.hash(routeDistinguisher);
62 }
63
64 @Override
65 public boolean equals(Object obj) {
66 if (this == obj) {
67 return true;
68 }
69
70 if (obj instanceof RouteDistinguisher) {
71 RouteDistinguisher other = (RouteDistinguisher) obj;
72 return Objects.equals(this.routeDistinguisher, other.routeDistinguisher);
73 }
74 return false;
75 }
76
77 @Override
78 public String toString() {
79 return toStringHelper(this)
80 .add("routeDistinguisher", this.routeDistinguisher).toString();
81 }
82}