722b870fed5642c99f96963a4edd14b2fe0507da
[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 package org.onosproject.net.resource.link;
17
18 import java.util.Objects;
19
20 import com.google.common.base.MoreObjects;
21 import org.onosproject.net.resource.ResourceRequest;
22 import org.onosproject.net.resource.ResourceType;
23
24 /**
25  * Representation of a request for bandwidth resource.
26  */
27 public class BandwidthResourceRequest implements ResourceRequest {
28     private final BandwidthResource bandwidth;
29
30     /**
31      * Creates a new {@link BandwidthResourceRequest} with {@link BandwidthResource}
32      * object.
33      *
34      * @param bandwidth {@link BandwidthResource} object to be requested
35      */
36     public BandwidthResourceRequest(BandwidthResource bandwidth) {
37         this.bandwidth = bandwidth;
38     }
39
40     /**
41      * Returns the bandwidth resource.
42      *
43      * @return the bandwidth resource
44      */
45     public BandwidthResource bandwidth() {
46         return bandwidth;
47     }
48
49     @Override
50     public ResourceType type() {
51         return ResourceType.BANDWIDTH;
52     }
53
54     @Override
55     public int hashCode() {
56         return bandwidth.hashCode();
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 BandwidthResourceRequest other = (BandwidthResourceRequest) obj;
68         return Objects.equals(this.bandwidth, other.bandwidth());
69     }
70
71     @Override
72     public String toString() {
73         return MoreObjects.toStringHelper(this)
74                 .add("bandwidth", bandwidth)
75                 .toString();
76     }
77 }