blob: bf72d4244e52d1b8eed2b20f9c965f2fd92bdda9 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.resource;
Toshio Koide485b4782014-10-20 19:34:21 -070017
Ayaka Koshibee114f042015-05-01 11:43:00 -070018import java.util.Objects;
19
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070020import com.google.common.base.MoreObjects;
21
Toshio Koide485b4782014-10-20 19:34:21 -070022/**
23 * Representation of a request for bandwidth resource.
24 */
Toshio Koidefa0dff62014-10-23 11:46:44 -070025public class BandwidthResourceRequest implements ResourceRequest {
Sho SHIMIZU63feca72015-05-07 10:44:25 -070026 private final BandwidthResource bandwidth;
Toshio Koide569ca702014-10-23 11:37:44 -070027
28 /**
Sho SHIMIZU63feca72015-05-07 10:44:25 -070029 * Creates a new {@link BandwidthResourceRequest} with {@link BandwidthResource}
Toshio Koide569ca702014-10-23 11:37:44 -070030 * object.
31 *
Sho SHIMIZU63feca72015-05-07 10:44:25 -070032 * @param bandwidth {@link BandwidthResource} object to be requested
Toshio Koide569ca702014-10-23 11:37:44 -070033 */
Sho SHIMIZU63feca72015-05-07 10:44:25 -070034 public BandwidthResourceRequest(BandwidthResource bandwidth) {
Toshio Koide569ca702014-10-23 11:37:44 -070035 this.bandwidth = bandwidth;
36 }
37
38 /**
Toshio Koide485b4782014-10-20 19:34:21 -070039 * Returns the bandwidth resource.
40 *
41 * @return the bandwidth resource
42 */
Sho SHIMIZU63feca72015-05-07 10:44:25 -070043 public BandwidthResource bandwidth() {
Toshio Koide569ca702014-10-23 11:37:44 -070044 return bandwidth;
45 }
Toshio Koideca0fcff2014-10-23 14:08:36 -070046
47 @Override
48 public ResourceType type() {
49 return ResourceType.BANDWIDTH;
50 }
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070051
52 @Override
Ayaka Koshibee114f042015-05-01 11:43:00 -070053 public int hashCode() {
54 return Objects.hash(bandwidth);
55 }
56
57 @Override
58 public boolean equals(Object obj) {
59 if (this == obj) {
60 return true;
61 }
62 if (obj == null || getClass() != obj.getClass()) {
63 return false;
64 }
65 final BandwidthResourceAllocation other = (BandwidthResourceAllocation) obj;
66 return Objects.equals(this.bandwidth, other.bandwidth());
67 }
68
69 @Override
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070070 public String toString() {
71 return MoreObjects.toStringHelper(this)
72 .add("bandwidth", bandwidth)
73 .toString();
74 }
Toshio Koide485b4782014-10-20 19:34:21 -070075}