| 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 VCloudNetworkAdapter 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().fromVCloudNetworkAdapter(this); |
| 41 | } |
| 42 | |
| 43 | public static class Builder extends ResourceAllocationSettingData.Builder { |
| 44 | private String ipAddress; |
| 45 | private boolean primaryNetworkConnection; |
| 46 | private String ipAddressingMode; |
| 47 | |
| 48 | /** |
| 49 | * @see VCloudNetworkAdapter#getCapacity |
| 50 | */ |
| 51 | public Builder ipAddress(String ipAddress) { |
| 52 | this.ipAddress = ipAddress; |
| 53 | return this; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @see VCloudNetworkAdapter#getBusType |
| 58 | */ |
| 59 | public Builder primaryNetworkConnection(boolean primaryNetworkConnection) { |
| 60 | this.primaryNetworkConnection = primaryNetworkConnection; |
| 61 | return this; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @see VCloudNetworkAdapter#getBusSubType |
| 66 | */ |
| 67 | public Builder ipAddressingMode(String ipAddressingMode) { |
| 68 | this.ipAddressingMode = ipAddressingMode; |
| 69 | return this; |
| 70 | } |
| 71 | |
| 72 | public VCloudNetworkAdapter build() { |
| 73 | return new VCloudNetworkAdapter(elementName, instanceID, caption, description, address, addressOnParent, |
| 74 | allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit, |
| 75 | mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, |
| 76 | virtualQuantity, virtualQuantityUnits, weight, connections, hostResources, ipAddress, |
| 77 | primaryNetworkConnection, ipAddressingMode); |
| 78 | } |
| 79 | |
| 80 | public Builder fromVCloudNetworkAdapter(VCloudNetworkAdapter in) { |
| 81 | return ipAddress(in.getIpAddress()).primaryNetworkConnection(in.isPrimaryNetworkConnection()) |
| 82 | .ipAddressingMode(in.getIpAddressingMode()).fromResourceAllocationSettingData(in); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * {@inheritDoc} |
| 87 | */ |
| 88 | @Override |
| 89 | public Builder caption(String caption) { |
| 90 | return Builder.class.cast(super.caption(caption)); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * {@inheritDoc} |
| 95 | */ |
| 96 | @Override |
| 97 | public Builder description(String description) { |
| 98 | return Builder.class.cast(super.description(description)); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * {@inheritDoc} |
| 103 | */ |
| 104 | @Override |
| 105 | public Builder elementName(String elementName) { |
| 106 | return Builder.class.cast(super.elementName(elementName)); |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * {@inheritDoc} |
| 111 | */ |
| 112 | @Override |
| 113 | public Builder instanceID(String instanceID) { |
| 114 | return Builder.class.cast(super.instanceID(instanceID)); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * {@inheritDoc} |
| 119 | */ |
| 120 | @Override |
| 121 | public Builder address(String address) { |
| 122 | return Builder.class.cast(super.address(address)); |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * {@inheritDoc} |
| 127 | */ |
| 128 | @Override |
| 129 | public Builder addressOnParent(String addressOnParent) { |
| 130 | return Builder.class.cast(super.addressOnParent(addressOnParent)); |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * {@inheritDoc} |
| 135 | */ |
| 136 | @Override |
| 137 | public Builder allocationUnits(String allocationUnits) { |
| 138 | return Builder.class.cast(super.allocationUnits(allocationUnits)); |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * {@inheritDoc} |
| 143 | */ |
| 144 | @Override |
| 145 | public Builder automaticAllocation(Boolean automaticAllocation) { |
| 146 | return Builder.class.cast(super.automaticAllocation(automaticAllocation)); |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * {@inheritDoc} |
| 151 | */ |
| 152 | @Override |
| 153 | public Builder automaticDeallocation(Boolean automaticDeallocation) { |
| 154 | return Builder.class.cast(super.automaticDeallocation(automaticDeallocation)); |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * {@inheritDoc} |
| 159 | */ |
| 160 | @Override |
| 161 | public Builder connection(String connection) { |
| 162 | return Builder.class.cast(super.connection(connection)); |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * {@inheritDoc} |
| 167 | */ |
| 168 | @Override |
| 169 | public Builder connections(List<String> connections) { |
| 170 | return Builder.class.cast(super.connections(connections)); |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * {@inheritDoc} |
| 175 | */ |
| 176 | @Override |
| 177 | public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { |
| 178 | return Builder.class.cast(super.consumerVisibility(consumerVisibility)); |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * {@inheritDoc} |
| 183 | */ |
| 184 | @Override |
| 185 | public Builder hostResource(String hostResource) { |
| 186 | return Builder.class.cast(super.hostResource(hostResource)); |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * {@inheritDoc} |
| 191 | */ |
| 192 | @Override |
| 193 | public Builder hostResources(List<String> hostResources) { |
| 194 | return Builder.class.cast(super.hostResources(hostResources)); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * {@inheritDoc} |
| 199 | */ |
| 200 | @Override |
| 201 | public Builder limit(Long limit) { |
| 202 | return Builder.class.cast(super.limit(limit)); |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * {@inheritDoc} |
| 207 | */ |
| 208 | @Override |
| 209 | public Builder mappingBehavior(MappingBehavior mappingBehavior) { |
| 210 | return Builder.class.cast(super.mappingBehavior(mappingBehavior)); |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * {@inheritDoc} |
| 215 | */ |
| 216 | @Override |
| 217 | public Builder otherResourceType(String otherResourceType) { |
| 218 | return Builder.class.cast(super.otherResourceType(otherResourceType)); |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * {@inheritDoc} |
| 223 | */ |
| 224 | @Override |
| 225 | public Builder parent(String parent) { |
| 226 | return Builder.class.cast(super.parent(parent)); |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * {@inheritDoc} |
| 231 | */ |
| 232 | @Override |
| 233 | public Builder poolID(String poolID) { |
| 234 | return Builder.class.cast(super.poolID(poolID)); |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * {@inheritDoc} |
| 239 | */ |
| 240 | @Override |
| 241 | public Builder reservation(Long reservation) { |
| 242 | return Builder.class.cast(super.reservation(reservation)); |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * {@inheritDoc} |
| 247 | */ |
| 248 | @Override |
| 249 | public Builder resourceSubType(String resourceSubType) { |
| 250 | return Builder.class.cast(super.resourceSubType(resourceSubType)); |
| 251 | } |
| 252 | |
| 253 | /** |
| 254 | * {@inheritDoc} |
| 255 | */ |
| 256 | @Override |
| 257 | public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) { |
| 258 | return Builder.class.cast(super.resourceType(resourceType)); |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * {@inheritDoc} |
| 263 | */ |
| 264 | @Override |
| 265 | public Builder virtualQuantity(Long virtualQuantity) { |
| 266 | return Builder.class.cast(super.virtualQuantity(virtualQuantity)); |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * {@inheritDoc} |
| 271 | */ |
| 272 | @Override |
| 273 | public Builder virtualQuantityUnits(String virtualQuantityUnits) { |
| 274 | return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits)); |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * {@inheritDoc} |
| 279 | */ |
| 280 | @Override |
| 281 | public Builder weight(Integer weight) { |
| 282 | return Builder.class.cast(super.weight(weight)); |
| 283 | } |
| 284 | |
| 285 | @Override |
| 286 | public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { |
| 287 | return Builder.class.cast(super.fromResourceAllocationSettingData(in)); |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | private final String ipAddress; |
| 292 | private final boolean primaryNetworkConnection; |
| 293 | private final String ipAddressingMode; |
| 294 | |
| 295 | public VCloudNetworkAdapter(String elementName, String instanceID, String caption, String description, |
| 296 | String address, String addressOnParent, String allocationUnits, Boolean automaticAllocation, |
| 297 | Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit, |
| 298 | MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation, |
| 299 | String resourceSubType, org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType, |
| 300 | Long virtualQuantity, String virtualQuantityUnits, Integer weight, List<String> connections, |
| 301 | List<String> hostResources, String ipAddress, boolean primaryNetworkConnection, String ipAddressingMode) { |
| 302 | super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, |
| 303 | automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, |
| 304 | otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, |
| 305 | virtualQuantityUnits, weight, connections, hostResources); |
| 306 | this.ipAddress = ipAddress; |
| 307 | this.primaryNetworkConnection = primaryNetworkConnection; |
| 308 | this.ipAddressingMode = ipAddressingMode; |
| 309 | } |
| 310 | |
| 311 | public String getIpAddress() { |
| 312 | return ipAddress; |
| 313 | } |
| 314 | |
| 315 | public boolean isPrimaryNetworkConnection() { |
| 316 | return primaryNetworkConnection; |
| 317 | } |
| 318 | |
| 319 | public String getIpAddressingMode() { |
| 320 | return ipAddressingMode; |
| 321 | } |
| 322 | |
| 323 | @Override |
| 324 | public String toString() { |
| 325 | return String |
| 326 | .format( |
| 327 | "[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, ipAddressingMode=%s, primaryNetworkConnection=%s, ipAddress=%s]", |
| 328 | elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, |
| 329 | automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, |
| 330 | limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, |
| 331 | resourceType, virtualQuantity, virtualQuantityUnits, weight, ipAddressingMode, |
| 332 | primaryNetworkConnection, ipAddress); |
| 333 | } |
| 334 | } |