blob: 722b870fed5642c99f96963a4edd14b2fe0507da [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'Connor6de2e202015-05-21 14:30:41 -070016package org.onosproject.net.resource.link;
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;
Brian O'Connor6de2e202015-05-21 14:30:41 -070021import org.onosproject.net.resource.ResourceRequest;
22import org.onosproject.net.resource.ResourceType;
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070023
Toshio Koide485b4782014-10-20 19:34:21 -070024/**
25 * Representation of a request for bandwidth resource.
26 */
Toshio Koidefa0dff62014-10-23 11:46:44 -070027public class BandwidthResourceRequest implements ResourceRequest {
Sho SHIMIZU63feca72015-05-07 10:44:25 -070028 private final BandwidthResource bandwidth;
Toshio Koide569ca702014-10-23 11:37:44 -070029
30 /**
Sho SHIMIZU63feca72015-05-07 10:44:25 -070031 * Creates a new {@link BandwidthResourceRequest} with {@link BandwidthResource}
Toshio Koide569ca702014-10-23 11:37:44 -070032 * object.
33 *
Sho SHIMIZU63feca72015-05-07 10:44:25 -070034 * @param bandwidth {@link BandwidthResource} object to be requested
Toshio Koide569ca702014-10-23 11:37:44 -070035 */
Sho SHIMIZU63feca72015-05-07 10:44:25 -070036 public BandwidthResourceRequest(BandwidthResource bandwidth) {
Toshio Koide569ca702014-10-23 11:37:44 -070037 this.bandwidth = bandwidth;
38 }
39
40 /**
Toshio Koide485b4782014-10-20 19:34:21 -070041 * Returns the bandwidth resource.
42 *
43 * @return the bandwidth resource
44 */
Sho SHIMIZU63feca72015-05-07 10:44:25 -070045 public BandwidthResource bandwidth() {
Toshio Koide569ca702014-10-23 11:37:44 -070046 return bandwidth;
47 }
Toshio Koideca0fcff2014-10-23 14:08:36 -070048
49 @Override
50 public ResourceType type() {
51 return ResourceType.BANDWIDTH;
52 }
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070053
54 @Override
Ayaka Koshibee114f042015-05-01 11:43:00 -070055 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070056 return bandwidth.hashCode();
Ayaka Koshibee114f042015-05-01 11:43:00 -070057 }
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 }
HIGUCHI Yutac7c1d352015-10-07 16:14:20 -070067 final BandwidthResourceRequest other = (BandwidthResourceRequest) obj;
Ayaka Koshibee114f042015-05-01 11:43:00 -070068 return Objects.equals(this.bandwidth, other.bandwidth());
69 }
70
71 @Override
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070072 public String toString() {
73 return MoreObjects.toStringHelper(this)
74 .add("bandwidth", bandwidth)
75 .toString();
76 }
Toshio Koide485b4782014-10-20 19:34:21 -070077}