Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.net.resource; |
| 18 | |
| 19 | import java.util.Objects; |
| 20 | |
| 21 | /** |
| 22 | * Representation of MPLS label resource. |
| 23 | */ |
| 24 | public final class MplsLabel extends LinkResource { |
| 25 | |
| 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 | } |