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 | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.resource; |
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; |
| 21 | |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Representation of a request for bandwidth resource. |
| 24 | */ |
Toshio Koide | fa0dff6 | 2014-10-23 11:46:44 -0700 | [diff] [blame] | 25 | public class BandwidthResourceRequest implements ResourceRequest { |
Toshio Koide | 569ca70 | 2014-10-23 11:37:44 -0700 | [diff] [blame] | 26 | private final Bandwidth bandwidth; |
| 27 | |
| 28 | /** |
| 29 | * Creates a new {@link BandwidthResourceRequest} with {@link Bandwidth} |
| 30 | * object. |
| 31 | * |
| 32 | * @param bandwidth {@link Bandwidth} object to be requested |
| 33 | */ |
| 34 | public BandwidthResourceRequest(Bandwidth bandwidth) { |
| 35 | this.bandwidth = bandwidth; |
| 36 | } |
| 37 | |
| 38 | /** |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 39 | * Returns the bandwidth resource. |
| 40 | * |
| 41 | * @return the bandwidth resource |
| 42 | */ |
Toshio Koide | d1865a4 | 2014-10-23 12:44:55 -0700 | [diff] [blame] | 43 | public Bandwidth bandwidth() { |
Toshio Koide | 569ca70 | 2014-10-23 11:37:44 -0700 | [diff] [blame] | 44 | return bandwidth; |
| 45 | } |
Toshio Koide | ca0fcff | 2014-10-23 14:08:36 -0700 | [diff] [blame] | 46 | |
| 47 | @Override |
| 48 | public ResourceType type() { |
| 49 | return ResourceType.BANDWIDTH; |
| 50 | } |
Brian O'Connor | fe0f4b1 | 2014-10-30 21:19:02 -0700 | [diff] [blame] | 51 | |
| 52 | @Override |
Ayaka Koshibe | e114f04 | 2015-05-01 11:43:00 -0700 | [diff] [blame] | 53 | 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'Connor | fe0f4b1 | 2014-10-30 21:19:02 -0700 | [diff] [blame] | 70 | public String toString() { |
| 71 | return MoreObjects.toStringHelper(this) |
| 72 | .add("bandwidth", bandwidth) |
| 73 | .toString(); |
| 74 | } |
Toshio Koide | 485b478 | 2014-10-20 19:34:21 -0700 | [diff] [blame] | 75 | } |