Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016 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 | */ |
| 16 | package org.onosproject.tetopology.management.api.link; |
| 17 | |
| 18 | import java.math.BigDecimal; |
| 19 | |
| 20 | import com.google.common.base.MoreObjects; |
| 21 | import com.google.common.base.Objects; |
| 22 | |
| 23 | /** |
| 24 | * Representation of a link's unreserved bandwidth. |
| 25 | */ |
| 26 | public class UnreservedBandwidth { |
| 27 | private final short priority; |
| 28 | private final BigDecimal bandwidth; |
| 29 | |
| 30 | /** |
| 31 | * Create an instance of UnreservedBandwidth. |
| 32 | * |
| 33 | * @param priority allocatable priority of unreserved bandwidth |
| 34 | * @param bandwidth bandwidth |
| 35 | */ |
| 36 | public UnreservedBandwidth(short priority, BigDecimal bandwidth) { |
| 37 | this.priority = priority; |
| 38 | this.bandwidth = bandwidth; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Returns the priority. |
| 43 | * |
| 44 | * @return the priority |
| 45 | */ |
| 46 | public short priority() { |
| 47 | return priority; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Returns the bandwidth. |
| 52 | * |
| 53 | * @return the bandwidth |
| 54 | */ |
| 55 | public BigDecimal bandwidth() { |
| 56 | return bandwidth; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public int hashCode() { |
| 61 | return Objects.hashCode(priority, bandwidth); |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public boolean equals(Object object) { |
| 66 | if (this == object) { |
| 67 | return true; |
| 68 | } |
| 69 | if (object instanceof UnreservedBandwidth) { |
| 70 | UnreservedBandwidth that = (UnreservedBandwidth) object; |
| 71 | return Objects.equal(this.priority, that.priority) && |
| 72 | Objects.equal(this.bandwidth, that.bandwidth); |
| 73 | } |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public String toString() { |
| 79 | return MoreObjects.toStringHelper(this) |
| 80 | .add("priority", priority) |
| 81 | .add("bandwidth", bandwidth) |
| 82 | .toString(); |
| 83 | } |
| 84 | |
| 85 | } |