blob: 89c87760ff0cd7f8d057531a24c4bd16702ada6f [file] [log] [blame]
Michele Santuari4b6019e2014-12-19 11:31:45 +01001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Michele Santuari4b6019e2014-12-19 11:31:45 +01003 *
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
Brian O'Connor6de2e202015-05-21 14:30:41 -070017package org.onosproject.net.resource.link;
Michele Santuari4b6019e2014-12-19 11:31:45 +010018
19import java.util.Objects;
20
21/**
22 * Representation of MPLS label resource.
23 */
Sho SHIMIZU1c221ad2015-07-02 10:08:08 -070024public final class MplsLabel implements LinkResource {
Michele Santuari4b6019e2014-12-19 11:31:45 +010025
26 private final org.onlab.packet.MplsLabel mplsLabel;
27
28
29 /**
30 * Creates a new instance with given MPLS label.
31 *
32 * @param mplsLabel MPLS Label value to be assigned
33 */
34 public MplsLabel(int mplsLabel) {
35 this.mplsLabel = org.onlab.packet.MplsLabel.mplsLabel(mplsLabel);
36 }
37
38 /**
39 * Creates a new instance with given MPLS label.
40 *
41 * @param mplsLabel mplsLabel value to be assigned
42 * @return {@link MplsLabel} instance with given bandwidth
43 */
44 public static MplsLabel valueOf(int mplsLabel) {
45 return new MplsLabel(mplsLabel);
46 }
47
48 /**
49 * Returns MPLS Label as an MPLS Label Object.
50 *
51 * @return MPLS label as an MPLS Label Object.
52 */
53 public org.onlab.packet.MplsLabel label() {
54 return mplsLabel;
55 }
56
57 @Override
58 public boolean equals(Object obj) {
59 if (obj instanceof MplsLabel) {
60 MplsLabel that = (MplsLabel) obj;
61 return Objects.equals(this.mplsLabel, that.mplsLabel);
62 }
63 return false;
64 }
65
66 @Override
67 public int hashCode() {
68 return Objects.hashCode(this.mplsLabel);
69 }
70
71 @Override
72 public String toString() {
73 return String.valueOf(this.mplsLabel);
74 }
75}