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