2 * Copyright 2014-2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onosproject.net.resource.link;
19 import com.google.common.base.MoreObjects;
20 import org.onosproject.net.resource.ResourceAllocation;
21 import org.onosproject.net.resource.ResourceType;
23 import java.util.Objects;
26 * Representation of allocated MPLS label resource.
28 public class MplsLabelResourceAllocation implements ResourceAllocation {
29 private final MplsLabel mplsLabel;
32 public ResourceType type() {
33 return ResourceType.MPLS_LABEL;
37 * Creates a new {@link MplsLabelResourceAllocation} with {@link MplsLabel}
40 * @param mplsLabel allocated MPLS Label
42 public MplsLabelResourceAllocation(MplsLabel mplsLabel) {
43 this.mplsLabel = mplsLabel;
47 * Returns the MPLS label resource.
49 * @return the MPLS label resource
51 public MplsLabel mplsLabel() {
56 public int hashCode() {
57 return Objects.hashCode(mplsLabel);
61 public boolean equals(Object obj) {
65 if (obj == null || getClass() != obj.getClass()) {
68 final MplsLabelResourceAllocation other = (MplsLabelResourceAllocation) obj;
69 return Objects.equals(this.mplsLabel, other.mplsLabel);
73 public String toString() {
74 return MoreObjects.toStringHelper(this)
75 .add("mplsLabel", mplsLabel)