cc9edc2ae249692bf8fe668a093453634229614b
[onosfw.git] /
1  /*
2  * Copyright 2014-2015 Open Networking Laboratory
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.link;
18
19 import com.google.common.base.MoreObjects;
20 import org.onosproject.net.resource.ResourceAllocation;
21 import org.onosproject.net.resource.ResourceType;
22
23 import java.util.Objects;
24
25 /**
26  * Representation of allocated MPLS label resource.
27  */
28 public class MplsLabelResourceAllocation implements ResourceAllocation {
29     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() {
57         return Objects.hashCode(mplsLabel);
58     }
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 }