blob: 558fc5a35147e8a769c469cf5c0bee911aa0adb3 [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
2 * Copyright 2016 Open Networking Laboratory
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 */
16package org.onosproject.tetopology.management.api.link;
17
18import java.util.Objects;
19
20import com.google.common.base.MoreObjects;
21
22/**
23 * Implementation of Label as an ElementType.
24 */
25public class Label implements ElementType {
26 private final long value;
27
28 /**
29 * Creates an instance of Label.
30 *
31 * @param label label value
32 */
33 public Label(long label) {
34 this.value = label;
35 }
36
37 /**
38 * Returns the label.
39 *
40 * @return value of the label
41 */
42 public long label() {
43 return value;
44 }
45
46 @Override
47 public int hashCode() {
48 return Objects.hash(value);
49 }
50
51 @Override
52 public boolean equals(Object obj) {
53 if (this == obj) {
54 return true;
55 }
56 if (obj instanceof Label) {
57 Label other = (Label) obj;
58 return
59 Objects.equals(value, other.value);
60 }
61 return false;
62 }
63
64 @Override
65 public String toString() {
66 return MoreObjects.toStringHelper(getClass())
67 .add("value", value)
68 .toString();
69 }
70}