Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 Open Networking Laboratory |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 | */ |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 16 | package org.onosproject.net.resource.link; |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 17 | |
Ayaka Koshibe | e114f04 | 2015-05-01 11:43:00 -0700 | [diff] [blame] | 18 | import java.util.Objects; |
| 19 | |
Brian O'Connor | fe0f4b1 | 2014-10-30 21:19:02 -0700 | [diff] [blame] | 20 | import com.google.common.base.MoreObjects; |
Brian O'Connor | 6de2e20 | 2015-05-21 14:30:41 -0700 | [diff] [blame] | 21 | import org.onosproject.net.resource.ResourceRequest; |
| 22 | import org.onosproject.net.resource.ResourceType; |
Brian O'Connor | fe0f4b1 | 2014-10-30 21:19:02 -0700 | [diff] [blame] | 23 | |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Representation of a request for bandwidth resource. |
| 26 | */ |
Toshio Koide | fa0dff6 | 2014-10-23 11:46:44 -0700 | [diff] [blame] | 27 | public class BandwidthResourceRequest implements ResourceRequest { |
Sho SHIMIZU | 63feca7 | 2015-05-07 10:44:25 -0700 | [diff] [blame] | 28 | private final BandwidthResource bandwidth; |
Toshio Koide | 569ca70 | 2014-10-23 11:37:44 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
Sho SHIMIZU | 63feca7 | 2015-05-07 10:44:25 -0700 | [diff] [blame] | 31 | * Creates a new {@link BandwidthResourceRequest} with {@link BandwidthResource} |
Toshio Koide | 569ca70 | 2014-10-23 11:37:44 -0700 | [diff] [blame] | 32 | * object. |
| 33 | * |
Sho SHIMIZU | 63feca7 | 2015-05-07 10:44:25 -0700 | [diff] [blame] | 34 | * @param bandwidth {@link BandwidthResource} object to be requested |
Toshio Koide | 569ca70 | 2014-10-23 11:37:44 -0700 | [diff] [blame] | 35 | */ |
Sho SHIMIZU | 63feca7 | 2015-05-07 10:44:25 -0700 | [diff] [blame] | 36 | public BandwidthResourceRequest(BandwidthResource bandwidth) { |
Toshio Koide | 569ca70 | 2014-10-23 11:37:44 -0700 | [diff] [blame] | 37 | this.bandwidth = bandwidth; |
| 38 | } |
| 39 | |
| 40 | /** |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 41 | * Returns the bandwidth resource. |
| 42 | * |
| 43 | * @return the bandwidth resource |
| 44 | */ |
Sho SHIMIZU | 63feca7 | 2015-05-07 10:44:25 -0700 | [diff] [blame] | 45 | public BandwidthResource bandwidth() { |
Toshio Koide | 569ca70 | 2014-10-23 11:37:44 -0700 | [diff] [blame] | 46 | return bandwidth; |
| 47 | } |
Toshio Koide | ca0fcff | 2014-10-23 14:08:36 -0700 | [diff] [blame] | 48 | |
| 49 | @Override |
| 50 | public ResourceType type() { |
| 51 | return ResourceType.BANDWIDTH; |
| 52 | } |
Brian O'Connor | fe0f4b1 | 2014-10-30 21:19:02 -0700 | [diff] [blame] | 53 | |
| 54 | @Override |
Ayaka Koshibe | e114f04 | 2015-05-01 11:43:00 -0700 | [diff] [blame] | 55 | public int hashCode() { |
| 56 | return Objects.hash(bandwidth); |
| 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 | } |
HIGUCHI Yuta | c7c1d35 | 2015-10-07 16:14:20 -0700 | [diff] [blame] | 67 | final BandwidthResourceRequest other = (BandwidthResourceRequest) obj; |
Ayaka Koshibe | e114f04 | 2015-05-01 11:43:00 -0700 | [diff] [blame] | 68 | return Objects.equals(this.bandwidth, other.bandwidth()); |
| 69 | } |
| 70 | |
| 71 | @Override |
Brian O'Connor | fe0f4b1 | 2014-10-30 21:19:02 -0700 | [diff] [blame] | 72 | public String toString() { |
| 73 | return MoreObjects.toStringHelper(this) |
| 74 | .add("bandwidth", bandwidth) |
| 75 | .toString(); |
| 76 | } |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 77 | } |