blob: 74f6e10215af741123dbca327f927163aecfe3a9 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 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 */
Brian O'Connor6de2e202015-05-21 14:30:41 -070016package org.onosproject.net.resource.link;
Toshio Koide485b4782014-10-20 19:34:21 -070017
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070018import com.google.common.base.MoreObjects;
Brian O'Connor6de2e202015-05-21 14:30:41 -070019import org.onosproject.net.resource.ResourceAllocation;
20import org.onosproject.net.resource.ResourceType;
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070021
Sho SHIMIZUc4d56612015-07-02 13:54:09 -070022import java.util.Objects;
23
Toshio Koide485b4782014-10-20 19:34:21 -070024/**
25 * Representation of allocated bandwidth resource.
26 */
Sho SHIMIZUc4d56612015-07-02 13:54:09 -070027public class BandwidthResourceAllocation implements ResourceAllocation {
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 BandwidthResourceAllocation(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 }
Toshio Koidea363f432014-10-23 12:49:40 -070048
49 @Override
50 public ResourceType type() {
51 return ResourceType.BANDWIDTH;
52 }
53
Sho SHIMIZUc4d56612015-07-02 13:54:09 -070054 @Override
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 }
67 final BandwidthResourceAllocation other = (BandwidthResourceAllocation) obj;
68 return Objects.equals(this.bandwidth, other.bandwidth());
Toshio Koidefa0dff62014-10-23 11:46:44 -070069 }
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070070
71 @Override
72 public String toString() {
73 return MoreObjects.toStringHelper(this)
Sho SHIMIZUc4d56612015-07-02 13:54:09 -070074 .add("bandwidth", bandwidth)
Brian O'Connorfe0f4b12014-10-30 21:19:02 -070075 .toString();
76 }
Toshio Koide485b4782014-10-20 19:34:21 -070077}