Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016 Open Networking Foundation |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [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 | */ |
| 16 | package org.onosproject.tetopology.management.api.link; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | import com.google.common.base.Objects; |
| 20 | |
| 21 | /** |
| 22 | * Representation of an ODU link resource. |
| 23 | */ |
| 24 | public class OduResource { |
| 25 | private final short odu0s; |
| 26 | private final short odu1s; |
| 27 | private final short odu2s; |
| 28 | private final short odu2es; |
| 29 | private final short odu3s; |
| 30 | private final short odu4s; |
| 31 | private final short oduFlexes; |
| 32 | |
| 33 | /** |
| 34 | * Creates an instance of an ODU link resource. |
| 35 | * |
| 36 | * @param odu0s number of available ODU0 containers |
| 37 | * @param odu1s number of available ODU1 containers |
| 38 | * @param odu2s number of available ODU2 containers |
| 39 | * @param odu2es number of available ODU2e containers |
| 40 | * @param odu3s number of available ODU3 containers |
| 41 | * @param odu4s number of available ODU4 containers |
| 42 | * @param oduFlexes available ODUflex bandwidth in terms of ODU0 containers |
| 43 | */ |
| 44 | public OduResource(short odu0s, short odu1s, short odu2s, |
| 45 | short odu2es, short odu3s, short odu4s, |
| 46 | short oduFlexes) { |
| 47 | this.odu0s = odu0s; |
| 48 | this.odu1s = odu1s; |
| 49 | this.odu2s = odu2s; |
| 50 | this.odu2es = odu2es; |
| 51 | this.odu3s = odu3s; |
| 52 | this.odu4s = odu4s; |
| 53 | this.oduFlexes = oduFlexes; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns the number of available ODU0s. |
| 58 | * |
| 59 | * @return the odu0s |
| 60 | */ |
| 61 | public short odu0s() { |
| 62 | return odu0s; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns the number of available ODU1s. |
| 67 | * |
| 68 | * @return the odu1s |
| 69 | */ |
| 70 | public short odu1s() { |
| 71 | return odu1s; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Returns the number of available ODU2s. |
| 76 | * |
| 77 | * @return the odu2s |
| 78 | */ |
| 79 | public short odu2s() { |
| 80 | return odu2s; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Returns the number of available ODU2es. |
| 85 | * |
| 86 | * @return the odu2es |
| 87 | */ |
| 88 | public short odu2es() { |
| 89 | return odu2es; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Returns the number of available ODU3s. |
| 94 | * |
| 95 | * @return the odu3s |
| 96 | */ |
| 97 | public short odu3s() { |
| 98 | return odu3s; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Returns the number of available ODU4s. |
| 103 | * |
| 104 | * @return the odu4s |
| 105 | */ |
| 106 | public short odu4s() { |
| 107 | return odu4s; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Returns available ODUflex bandwidth in terms of ODU0 containers. |
| 112 | * |
| 113 | * @return the oduFlexes |
| 114 | */ |
| 115 | public short oduFlexes() { |
| 116 | return oduFlexes; |
| 117 | } |
| 118 | |
| 119 | @Override |
| 120 | public int hashCode() { |
| 121 | return Objects.hashCode(odu0s, odu1s, odu2s, odu2es, odu3s, |
| 122 | odu4s, oduFlexes); |
| 123 | } |
| 124 | |
| 125 | @Override |
| 126 | public boolean equals(Object object) { |
| 127 | if (this == object) { |
| 128 | return true; |
| 129 | } |
| 130 | if (object instanceof OduResource) { |
| 131 | OduResource that = (OduResource) object; |
| 132 | return (this.odu0s == that.odu0s) && |
| 133 | (this.odu1s == that.odu1s) && |
| 134 | (this.odu2s == that.odu2s) && |
| 135 | (this.odu2es == that.odu2es) && |
| 136 | (this.odu3s == that.odu3s) && |
| 137 | (this.odu4s == that.odu4s) && |
| 138 | (this.oduFlexes == that.oduFlexes); |
| 139 | } |
| 140 | return false; |
| 141 | } |
| 142 | |
| 143 | @Override |
| 144 | public String toString() { |
| 145 | return MoreObjects.toStringHelper(this) |
| 146 | .add("odu0s", odu0s) |
| 147 | .add("odu1s", odu1s) |
| 148 | .add("odu2s", odu2s) |
| 149 | .add("odu2es", odu2es) |
| 150 | .add("odu3s", odu3s) |
| 151 | .add("odu4s", odu4s) |
| 152 | .add("oduFlexes", oduFlexes) |
| 153 | .toString(); |
| 154 | } |
| 155 | |
| 156 | |
| 157 | } |