| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.vcloud.domain.ovf; |
| 20 | |
| 21 | import java.util.List; |
| 22 | |
| 23 | import org.jclouds.cim.ResourceAllocationSettingData; |
| 24 | |
| 25 | /** |
| 26 | * @author Adrian Cole |
| 27 | * |
| 28 | */ |
| 29 | public class VCloudHardDisk extends ResourceAllocationSettingData { |
| 30 | |
| 31 | public static Builder builder() { |
| 32 | return new Builder(); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * {@inheritDoc} |
| 37 | */ |
| 38 | @Override |
| 39 | public Builder toBuilder() { |
| 40 | return builder().fromVCloudHardDisk(this); |
| 41 | } |
| 42 | |
| 43 | public static class Builder extends ResourceAllocationSettingData.Builder { |
| 44 | private long capacity; |
| 45 | private int busType; |
| 46 | private String busSubType; |
| 47 | |
| 48 | /** |
| 49 | * @see VCloudHardDisk#getCapacity |
| 50 | */ |
| 51 | public Builder capacity(long capacity) { |
| 52 | this.capacity = capacity; |
| 53 | return this; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @see VCloudHardDisk#getBusType |
| 58 | */ |
| 59 | public Builder busType(int busType) { |
| 60 | this.busType = busType; |
| 61 | return this; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @see VCloudHardDisk#getBusSubType |
| 66 | */ |
| 67 | public Builder busSubType(String busSubType) { |
| 68 | this.busSubType = busSubType; |
| 69 | return this; |
| 70 | } |
| 71 | |
| 72 | public VCloudHardDisk build() { |
| 73 | return new VCloudHardDisk(elementName, instanceID, caption, description, address, addressOnParent, |
| 74 | allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, |
| 75 | otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, |
| 76 | virtualQuantityUnits, weight, connections, hostResources, capacity, busType, busSubType); |
| 77 | } |
| 78 | |
| 79 | public Builder fromVCloudHardDisk(VCloudHardDisk in) { |
| 80 | return capacity(in.getCapacity()).busType(in.getBusType()).busSubType(in.getBusSubType()) |
| 81 | .fromResourceAllocationSettingData(in); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * {@inheritDoc} |
| 86 | */ |
| 87 | @Override |
| 88 | public Builder caption(String caption) { |
| 89 | return Builder.class.cast(super.caption(caption)); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * {@inheritDoc} |
| 94 | */ |
| 95 | @Override |
| 96 | public Builder description(String description) { |
| 97 | return Builder.class.cast(super.description(description)); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * {@inheritDoc} |
| 102 | */ |
| 103 | @Override |
| 104 | public Builder elementName(String elementName) { |
| 105 | return Builder.class.cast(super.elementName(elementName)); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * {@inheritDoc} |
| 110 | */ |
| 111 | @Override |
| 112 | public Builder instanceID(String instanceID) { |
| 113 | return Builder.class.cast(super.instanceID(instanceID)); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * {@inheritDoc} |
| 118 | */ |
| 119 | @Override |
| 120 | public Builder address(String address) { |
| 121 | return Builder.class.cast(super.address(address)); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * {@inheritDoc} |
| 126 | */ |
| 127 | @Override |
| 128 | public Builder addressOnParent(String addressOnParent) { |
| 129 | return Builder.class.cast(super.addressOnParent(addressOnParent)); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * {@inheritDoc} |
| 134 | */ |
| 135 | @Override |
| 136 | public Builder allocationUnits(String allocationUnits) { |
| 137 | return Builder.class.cast(super.allocationUnits(allocationUnits)); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * {@inheritDoc} |
| 142 | */ |
| 143 | @Override |
| 144 | public Builder automaticAllocation(Boolean automaticAllocation) { |
| 145 | return Builder.class.cast(super.automaticAllocation(automaticAllocation)); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * {@inheritDoc} |
| 150 | */ |
| 151 | @Override |
| 152 | public Builder automaticDeallocation(Boolean automaticDeallocation) { |
| 153 | return Builder.class.cast(super.automaticDeallocation(automaticDeallocation)); |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * {@inheritDoc} |
| 158 | */ |
| 159 | @Override |
| 160 | public Builder connection(String connection) { |
| 161 | return Builder.class.cast(super.connection(connection)); |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * {@inheritDoc} |
| 166 | */ |
| 167 | @Override |
| 168 | public Builder connections(List<String> connections) { |
| 169 | return Builder.class.cast(super.connections(connections)); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * {@inheritDoc} |
| 174 | */ |
| 175 | @Override |
| 176 | public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { |
| 177 | return Builder.class.cast(super.consumerVisibility(consumerVisibility)); |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * {@inheritDoc} |
| 182 | */ |
| 183 | @Override |
| 184 | public Builder hostResource(String hostResource) { |
| 185 | return Builder.class.cast(super.hostResource(hostResource)); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * {@inheritDoc} |
| 190 | */ |
| 191 | @Override |
| 192 | public Builder hostResources(List<String> hostResources) { |
| 193 | return Builder.class.cast(super.hostResources(hostResources)); |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * {@inheritDoc} |
| 198 | */ |
| 199 | @Override |
| 200 | public Builder limit(Long limit) { |
| 201 | return Builder.class.cast(super.limit(limit)); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * {@inheritDoc} |
| 206 | */ |
| 207 | @Override |
| 208 | public Builder mappingBehavior(MappingBehavior mappingBehavior) { |
| 209 | return Builder.class.cast(super.mappingBehavior(mappingBehavior)); |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * {@inheritDoc} |
| 214 | */ |
| 215 | @Override |
| 216 | public Builder otherResourceType(String otherResourceType) { |
| 217 | return Builder.class.cast(super.otherResourceType(otherResourceType)); |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * {@inheritDoc} |
| 222 | */ |
| 223 | @Override |
| 224 | public Builder parent(String parent) { |
| 225 | return Builder.class.cast(super.parent(parent)); |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * {@inheritDoc} |
| 230 | */ |
| 231 | @Override |
| 232 | public Builder poolID(String poolID) { |
| 233 | return Builder.class.cast(super.poolID(poolID)); |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * {@inheritDoc} |
| 238 | */ |
| 239 | @Override |
| 240 | public Builder reservation(Long reservation) { |
| 241 | return Builder.class.cast(super.reservation(reservation)); |
| 242 | } |
| 243 | |
| 244 | /** |
| 245 | * {@inheritDoc} |
| 246 | */ |
| 247 | @Override |
| 248 | public Builder resourceSubType(String resourceSubType) { |
| 249 | return Builder.class.cast(super.resourceSubType(resourceSubType)); |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * {@inheritDoc} |
| 254 | */ |
| 255 | @Override |
| 256 | public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) { |
| 257 | return Builder.class.cast(super.resourceType(resourceType)); |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * {@inheritDoc} |
| 262 | */ |
| 263 | @Override |
| 264 | public Builder virtualQuantity(Long virtualQuantity) { |
| 265 | return Builder.class.cast(super.virtualQuantity(virtualQuantity)); |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * {@inheritDoc} |
| 270 | */ |
| 271 | @Override |
| 272 | public Builder virtualQuantityUnits(String virtualQuantityUnits) { |
| 273 | return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits)); |
| 274 | } |
| 275 | |
| 276 | /** |
| 277 | * {@inheritDoc} |
| 278 | */ |
| 279 | @Override |
| 280 | public Builder weight(Integer weight) { |
| 281 | return Builder.class.cast(super.weight(weight)); |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { |
| 286 | return Builder.class.cast(super.fromResourceAllocationSettingData(in)); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | private final long capacity; |
| 291 | private final int busType; |
| 292 | private final String busSubType; |
| 293 | |
| 294 | public VCloudHardDisk(String elementName, String instanceID, String caption, String description, String address, |
| 295 | String addressOnParent, String allocationUnits, Boolean automaticAllocation, Boolean automaticDeallocation, |
| 296 | ConsumerVisibility consumerVisibility, Long limit, MappingBehavior mappingBehavior, String otherResourceType, |
| 297 | String parent, String poolID, Long reservation, String resourceSubType, |
| 298 | org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType, Long virtualQuantity, |
| 299 | String virtualQuantityUnits, Integer weight, List<String> connections, List<String> hostResources, |
| 300 | long capacity, int busType, String busSubType) { |
| 301 | super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, |
| 302 | automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, otherResourceType, |
| 303 | parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, virtualQuantityUnits, weight, |
| 304 | connections, hostResources); |
| 305 | this.capacity = capacity; |
| 306 | this.busType = busType; |
| 307 | this.busSubType = busSubType; |
| 308 | } |
| 309 | |
| 310 | public long getCapacity() { |
| 311 | return capacity; |
| 312 | } |
| 313 | |
| 314 | public int getBusType() { |
| 315 | return busType; |
| 316 | } |
| 317 | |
| 318 | public String getBusSubType() { |
| 319 | return busSubType; |
| 320 | } |
| 321 | |
| 322 | @Override |
| 323 | public String toString() { |
| 324 | return String |
| 325 | .format( |
| 326 | "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s, busSubType=%s, busType=%s, capacity=%s]", |
| 327 | elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, |
| 328 | automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, limit, |
| 329 | mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, |
| 330 | virtualQuantity, virtualQuantityUnits, weight, busSubType, busType, capacity); |
| 331 | } |
| 332 | } |