blob: 8d90611ff5765d6916068740e35a480c5f3b7e41 [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;
22
23/**
24 * Represents label of the route.
25 */
26public final class Label {
27 private final int label;
28
29 /**
30 * Constructor to initialize parameters.
31 *
32 * @param label route label
33 */
34 private Label(int label) {
35 this.label = label;
36 }
37
38 /**
39 * Creates the label for evpn route.
40 *
41 * @param label label of evpn route
42 * @return Label
43 */
44 public static Label label(int label) {
45 return new Label(label);
46 }
47
48 /**
49 * Returns the label.
50 *
51 * @return label
52 */
53 public int getLabel() {
54 return label;
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hash(label);
60 }
61
62 @Override
63 public boolean equals(Object obj) {
64 if (this == obj) {
65 return true;
66 }
67
68 if (obj instanceof Label) {
69 Label other = (Label) obj;
70 return Objects.equals(label, other.label);
71 }
72 return false;
73 }
74
75 @Override
76 public String toString() {
77 return toStringHelper(this).add("label", label).toString();
78 }
79}