| 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.net.URI; |
| 22 | |
| 23 | import org.jclouds.cim.ResourceAllocationSettingData; |
| 24 | import org.jclouds.cim.VirtualSystemSettingData; |
| 25 | import org.jclouds.ovf.Section; |
| 26 | import org.jclouds.ovf.VirtualHardwareSection; |
| 27 | |
| 28 | /** |
| 29 | * A description of the virtual hardware supported by a virtual machine. |
| 30 | */ |
| 31 | public class VCloudVirtualHardwareSection extends VirtualHardwareSection { |
| 32 | public static Builder builder() { |
| 33 | return new Builder(); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * {@inheritDoc} |
| 38 | */ |
| 39 | @Override |
| 40 | public Builder toBuilder() { |
| 41 | return builder().fromVCloudVirtualHardwareSection(this); |
| 42 | } |
| 43 | |
| 44 | public static class Builder extends VirtualHardwareSection.Builder { |
| 45 | protected String type; |
| 46 | protected URI href; |
| 47 | |
| 48 | /** |
| 49 | * @see VCloudVirtualHardware#getType |
| 50 | */ |
| 51 | public Builder type(String type) { |
| 52 | this.type = type; |
| 53 | return this; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * @see VCloudVirtualHardware#getHref |
| 58 | */ |
| 59 | public Builder href(URI href) { |
| 60 | this.href = href; |
| 61 | return this; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * {@inheritDoc} |
| 66 | */ |
| 67 | @Override |
| 68 | public Builder system(VirtualSystemSettingData virtualSystem) { |
| 69 | return Builder.class.cast(super.system(virtualSystem)); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * {@inheritDoc} |
| 74 | */ |
| 75 | @Override |
| 76 | public Builder transport(String transport) { |
| 77 | return Builder.class.cast(super.transport(transport)); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * {@inheritDoc} |
| 82 | */ |
| 83 | @Override |
| 84 | public Builder transports(Iterable<String> transports) { |
| 85 | return Builder.class.cast(super.transports(transports)); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * {@inheritDoc} |
| 90 | */ |
| 91 | @Override |
| 92 | public Builder item(ResourceAllocationSettingData item) { |
| 93 | return Builder.class.cast(super.item(item)); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * {@inheritDoc} |
| 98 | */ |
| 99 | @Override |
| 100 | public Builder items(Iterable<? extends ResourceAllocationSettingData> items) { |
| 101 | return Builder.class.cast(super.items(items)); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * {@inheritDoc} |
| 106 | */ |
| 107 | @Override |
| 108 | public VCloudVirtualHardwareSection build() { |
| 109 | return new VCloudVirtualHardwareSection(type, href, info, transports, virtualSystem, items); |
| 110 | } |
| 111 | |
| 112 | public Builder fromVCloudVirtualHardwareSection(VCloudVirtualHardwareSection in) { |
| 113 | return fromVirtualHardwareSection(in).type(in.getType()).href(in.getHref()); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * {@inheritDoc} |
| 118 | */ |
| 119 | @Override |
| 120 | public Builder fromVirtualHardwareSection(VirtualHardwareSection in) { |
| 121 | return Builder.class.cast(super.fromVirtualHardwareSection(in)); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * {@inheritDoc} |
| 126 | */ |
| 127 | @Override |
| 128 | public Builder fromSection(Section<VirtualHardwareSection> in) { |
| 129 | return Builder.class.cast(super.fromSection(in)); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * {@inheritDoc} |
| 134 | */ |
| 135 | @Override |
| 136 | public Builder info(String info) { |
| 137 | return Builder.class.cast(super.info(info)); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | protected final String type; |
| 142 | protected final URI href; |
| 143 | |
| 144 | public VCloudVirtualHardwareSection(String type, URI href, String info, Iterable<String> transports, |
| 145 | VirtualSystemSettingData virtualSystem, Iterable<? extends ResourceAllocationSettingData> resourceAllocations) { |
| 146 | super(info, transports, virtualSystem, resourceAllocations); |
| 147 | this.type = type; |
| 148 | this.href = href; |
| 149 | } |
| 150 | |
| 151 | public String getType() { |
| 152 | return type; |
| 153 | } |
| 154 | |
| 155 | public URI getHref() { |
| 156 | return href; |
| 157 | } |
| 158 | |
| 159 | @Override |
| 160 | public int hashCode() { |
| 161 | return href.hashCode(); |
| 162 | } |
| 163 | |
| 164 | @Override |
| 165 | public boolean equals(Object obj) { |
| 166 | if (this == obj) |
| 167 | return true; |
| 168 | if (!super.equals(obj)) |
| 169 | return false; |
| 170 | if (getClass() != obj.getClass()) |
| 171 | return false; |
| 172 | VCloudVirtualHardwareSection other = (VCloudVirtualHardwareSection) obj; |
| 173 | return href.equals(other.href); |
| 174 | } |
| 175 | |
| 176 | @Override |
| 177 | public String toString() { |
| 178 | return "[href=" + getHref() + ", type=" + getType() + ", info=" + getInfo() + ", virtualSystem=" + getSystem() |
| 179 | + "]"; |
| 180 | } |
| 181 | } |