blob: cc9edc2ae249692bf8fe668a093453634229614b [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 */
Sho SHIMIZUc4d56612015-07-02 13:54:09 -070028public class MplsLabelResourceAllocation implements ResourceAllocation {
Michele Santuari4b6019e2014-12-19 11:31:45 +010029 private final MplsLabel mplsLabel;
30
31 @Override
32 public ResourceType type() {
33 return ResourceType.MPLS_LABEL;
34 }
35
36 /**
37 * Creates a new {@link MplsLabelResourceAllocation} with {@link MplsLabel}
38 * object.
39 *
40 * @param mplsLabel allocated MPLS Label
41 */
42 public MplsLabelResourceAllocation(MplsLabel mplsLabel) {
43 this.mplsLabel = mplsLabel;
44 }
45
46 /**
47 * Returns the MPLS label resource.
48 *
49 * @return the MPLS label resource
50 */
51 public MplsLabel mplsLabel() {
52 return mplsLabel;
53 }
54
55 @Override
56 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070057 return Objects.hashCode(mplsLabel);
Michele Santuari4b6019e2014-12-19 11:31:45 +010058 }
59
60 @Override
61 public boolean equals(Object obj) {
62 if (this == obj) {
63 return true;
64 }
65 if (obj == null || getClass() != obj.getClass()) {
66 return false;
67 }
68 final MplsLabelResourceAllocation other = (MplsLabelResourceAllocation) obj;
69 return Objects.equals(this.mplsLabel, other.mplsLabel);
70 }
71
72 @Override
73 public String toString() {
74 return MoreObjects.toStringHelper(this)
75 .add("mplsLabel", mplsLabel)
76 .toString();
77 }
78}