blob: 1b3b8fce86323b6d1932f3f6a3c1e110756b1f8b [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 com.google.common.base.MoreObjects;
Brian O'Connor6de2e202015-05-21 14:30:41 -070020import org.onosproject.net.resource.ResourceAllocation;
21import org.onosproject.net.resource.ResourceType;
Michele Santuari4b6019e2014-12-19 11:31:45 +010022
23import java.util.Objects;
24
25/**
26 * Representation of allocated MPLS label resource.
27 */
28public class MplsLabelResourceAllocation extends MplsLabelResourceRequest
29 implements ResourceAllocation {
30 private final MplsLabel mplsLabel;
31
32 @Override
33 public ResourceType type() {
34 return ResourceType.MPLS_LABEL;
35 }
36
37 /**
38 * Creates a new {@link MplsLabelResourceAllocation} with {@link MplsLabel}
39 * object.
40 *
41 * @param mplsLabel allocated MPLS Label
42 */
43 public MplsLabelResourceAllocation(MplsLabel mplsLabel) {
44 this.mplsLabel = mplsLabel;
45 }
46
47 /**
48 * Returns the MPLS label resource.
49 *
50 * @return the MPLS label resource
51 */
52 public MplsLabel mplsLabel() {
53 return mplsLabel;
54 }
55
56 @Override
57 public int hashCode() {
58 return Objects.hash(mplsLabel);
59 }
60
61 @Override
62 public boolean equals(Object obj) {
63 if (this == obj) {
64 return true;
65 }
66 if (obj == null || getClass() != obj.getClass()) {
67 return false;
68 }
69 final MplsLabelResourceAllocation other = (MplsLabelResourceAllocation) obj;
70 return Objects.equals(this.mplsLabel, other.mplsLabel);
71 }
72
73 @Override
74 public String toString() {
75 return MoreObjects.toStringHelper(this)
76 .add("mplsLabel", mplsLabel)
77 .toString();
78 }
79}