Update usage of collections of OVF sections

This commit is contained in:
Andrew Donald Kennedy 2012-04-10 13:13:25 +01:00
parent 74b5ef76e7
commit 98f0c51b28
8 changed files with 286 additions and 277 deletions

View File

@ -137,7 +137,7 @@ public abstract class BaseEnvelope<V extends BaseVirtualSystem, E extends BaseEn
return virtualSystem; return virtualSystem;
} }
public Set<? extends DiskSection> getDiskSections() { public Set<DiskSection> getDiskSections() {
return diskSections; return diskSections;
} }

View File

@ -74,7 +74,7 @@ public abstract class BaseVirtualSystem extends SectionType {
/** /**
* @see BaseVirtualSystem#getProductSections() * @see BaseVirtualSystem#getProductSections()
*/ */
public B productSections(Iterable<? extends ProductSection> productSections) { public B productSections(Iterable<ProductSection> productSections) {
this.productSections = Sets.newLinkedHashSet(checkNotNull(productSections, "productSections")); this.productSections = Sets.newLinkedHashSet(checkNotNull(productSections, "productSections"));
return self(); return self();
} }
@ -109,9 +109,9 @@ public abstract class BaseVirtualSystem extends SectionType {
@XmlElement(name = "Name") @XmlElement(name = "Name")
private String name; private String name;
@XmlElement(name = "ProductSection") @XmlElement(name = "ProductSection")
private Set<? extends ProductSection> productSections; private Set<ProductSection> productSections;
@XmlElementRef @XmlElementRef
private Set<? extends SectionType> additionalSections; private Set<SectionType> additionalSections;
protected BaseVirtualSystem(Builder<?> builder) { protected BaseVirtualSystem(Builder<?> builder) {
super(builder); super(builder);
@ -137,11 +137,11 @@ public abstract class BaseVirtualSystem extends SectionType {
* Specifies product-information for a package, such as product name and version, along with a * Specifies product-information for a package, such as product name and version, along with a
* set of properties that can be configured * set of properties that can be configured
*/ */
public Set<? extends ProductSection> getProductSections() { public Set<ProductSection> getProductSections() {
return productSections; return productSections;
} }
public Set<? extends SectionType> getAdditionalSections() { public Set<SectionType> getAdditionalSections() {
return additionalSections; return additionalSections;
} }

View File

@ -21,19 +21,28 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List; import java.util.Collections;
import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import org.jclouds.dmtf.DMTFConstants; import org.jclouds.dmtf.ovf.DeploymentOptionSection;
import org.jclouds.dmtf.ovf.DiskSection;
import org.jclouds.dmtf.ovf.NetworkSection;
import org.jclouds.dmtf.ovf.OperatingSystemSection;
import org.jclouds.dmtf.ovf.ProductSection;
import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.SectionType;
import org.jclouds.dmtf.ovf.StartupSection;
import org.jclouds.dmtf.ovf.VirtualHardwareSection;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Lists; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
/** /**
* Represents a base type for VAppType and VmType. * Represents a base type for VAppType and VmType.
@ -63,7 +72,7 @@ public abstract class AbstractVAppType extends ResourceEntityType {
private Boolean deployed; private Boolean deployed;
private Reference vAppParent; private Reference vAppParent;
private List<SectionType> sections = Lists.newArrayList(); private Set<SectionType> sections = Sets.newLinkedHashSet();
/** /**
* @see AbstractVAppType#isDeployed() * @see AbstractVAppType#isDeployed()
@ -101,7 +110,7 @@ public abstract class AbstractVAppType extends ResourceEntityType {
* @see AbstractVAppType#getSections() * @see AbstractVAppType#getSections()
*/ */
public B sections(Iterable<? extends SectionType> sections) { public B sections(Iterable<? extends SectionType> sections) {
this.sections = Lists.newArrayList(checkNotNull(sections, "sections")); this.sections = Sets.newLinkedHashSet(checkNotNull(sections, "sections"));
return self(); return self();
} }
@ -109,8 +118,6 @@ public abstract class AbstractVAppType extends ResourceEntityType {
* @see AbstractVAppType#getSections() * @see AbstractVAppType#getSections()
*/ */
public B section(SectionType section) { public B section(SectionType section) {
if (this.sections == null)
this.sections = Lists.newArrayList();
this.sections.add(checkNotNull(section, "section")); this.sections.add(checkNotNull(section, "section"));
return self(); return self();
} }
@ -122,8 +129,26 @@ public abstract class AbstractVAppType extends ResourceEntityType {
@XmlElement(name = "VAppParent") @XmlElement(name = "VAppParent")
private Reference vAppParent; private Reference vAppParent;
@XmlElementRef(namespace = DMTFConstants.OVF_NS) @XmlElementRefs({
private List<? extends SectionType> sections = Lists.newArrayList(); @XmlElementRef(type = VirtualHardwareSection.class),
@XmlElementRef(type = LeaseSettingsSection.class),
// @XmlElementRef(type = EulaSection.class),
@XmlElementRef(type = RuntimeInfoSection.class),
// @XmlElementRef(type = AnnotationSection.class),
@XmlElementRef(type = DeploymentOptionSection.class),
@XmlElementRef(type = StartupSection.class),
// @XmlElementRef(type = ResourceAllocationSection.class),
@XmlElementRef(type = NetworkConnectionSection.class),
@XmlElementRef(type = CustomizationSection.class),
@XmlElementRef(type = ProductSection.class),
@XmlElementRef(type = GuestCustomizationSection.class),
@XmlElementRef(type = OperatingSystemSection.class),
@XmlElementRef(type = NetworkConfigSection.class),
@XmlElementRef(type = NetworkSection.class),
// @XmlElementRef(type = InstallSection.class),
@XmlElementRef(type = DiskSection.class)
})
private Set<SectionType> sections = Sets.newLinkedHashSet();
@XmlAttribute @XmlAttribute
private Boolean deployed; private Boolean deployed;
@ -134,7 +159,7 @@ public abstract class AbstractVAppType extends ResourceEntityType {
protected AbstractVAppType(Builder<?> builder) { protected AbstractVAppType(Builder<?> builder) {
super(builder); super(builder);
this.vAppParent = builder.vAppParent; this.vAppParent = builder.vAppParent;
this.sections = builder.sections; this.sections = builder.sections.isEmpty() ? null : ImmutableSet.copyOf(builder.sections);
this.deployed = builder.deployed; this.deployed = builder.deployed;
} }
@ -146,32 +171,31 @@ public abstract class AbstractVAppType extends ResourceEntityType {
} }
/** /**
* Specific ovf:Section with additional information for the vApp. * Specific {@code ovf:Section} with additional information for the vApp.
* *
* Objects of the following type(s) are allowed in the list: * Objects of the following type(s) are allowed in the list:
* <ul> * <ul>
* <li>SectionType * <li>{@link VirtualHardwareSectionType}
* <li>VirtualHardwareSectionType * <li>{@link LeaseSettingsSectionType}
* <li>LeaseSettingsSectionType * <li>{@link EulaSectionType}
* <li>EulaSectionType * <li>{@link RuntimeInfoSectionType}
* <li>RuntimeInfoSectionType * <li>{@link AnnotationSectionType}
* <li>AnnotationSectionType * <li>{@link DeploymentOptionSectionType}
* <li>DeploymentOptionSectionType * <li>{@link StartupSectionType}
* <li>StartupSectionType * <li>{@link ResourceAllocationSectionType}
* <li>ResourceAllocationSectionType * <li>{@link NetworkConnectionSectionType}
* <li>NetworkConnectionSectionType * <li>{@link CustomizationSectionType}
* <li>CustomizationSectionType * <li>{@link ProductSectionType}
* <li>ProductSectionType * <li>{@link GuestCustomizationSectionType}
* <li>GuestCustomizationSectionType * <li>{@link OperatingSystemSectionType}
* <li>OperatingSystemSectionType * <li>{@link NetworkConfigSectionType}
* <li>NetworkConfigSectionType * <li>{@link NetworkSectionType}
* <li>NetworkSectionType * <li>{@link DiskSectionType}
* <li>DiskSectionType * <li>{@link InstallSectionType}
* <li>InstallSectionType
* </ul> * </ul>
*/ */
public List<? extends SectionType> getSections() { public Set<SectionType> getSections() {
return this.sections; return sections != null ? ImmutableSet.copyOf(sections) : Collections.<SectionType>emptySet();
} }
/** /**

View File

@ -1,4 +1,4 @@
/** /*
* Licensed to jclouds, Inc. (jclouds) under one or more * Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file * contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
@ -16,7 +16,6 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
@ -28,24 +27,26 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import org.jclouds.dmtf.ovf.DeploymentOptionSection;
import org.jclouds.dmtf.ovf.DiskSection;
import org.jclouds.dmtf.ovf.NetworkSection;
import org.jclouds.dmtf.ovf.OperatingSystemSection;
import org.jclouds.dmtf.ovf.ProductSection;
import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.SectionType;
import org.jclouds.dmtf.ovf.StartupSection;
import org.jclouds.dmtf.ovf.VirtualHardwareSection;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
* Represents the parameters for capturing a vApp to a vApp template. * Represents the parameters for capturing a vApp to a vApp template.
* <p/> *
* <p/>
* <p>Java class for CaptureVAppParams complex type.
* <p/>
* <p>The following schema fragment specifies the expected content contained within this class.
* <p/>
* <pre> * <pre>
* &lt;complexType name="CaptureVAppParams"> * &lt;complexType name="CaptureVAppParams">
* &lt;complexContent> * &lt;complexContent>
@ -82,7 +83,7 @@ public class CaptureVAppParams extends ParamsType {
public static abstract class Builder<B extends Builder<B>> extends ParamsType.Builder<B> { public static abstract class Builder<B extends Builder<B>> extends ParamsType.Builder<B> {
private Reference source; private Reference source;
private Set<? extends SectionType> sections = Sets.newLinkedHashSet(); private Set<SectionType> sections = Sets.newLinkedHashSet();
/** /**
* @see CaptureVAppParams#getSource() * @see CaptureVAppParams#getSource()
@ -105,8 +106,16 @@ public class CaptureVAppParams extends ParamsType {
/** /**
* @see CaptureVAppParams#getSections() * @see CaptureVAppParams#getSections()
*/ */
public B sections(Set<? extends SectionType> sections) { public B section(SectionType section) {
this.sections = checkNotNull(sections, "sections"); this.sections.add(checkNotNull(section, "section"));
return self();
}
/**
* @see CaptureVAppParams#getSections()
*/
public B sections(Iterable<? extends SectionType> sections) {
this.sections = Sets.newLinkedHashSet(checkNotNull(sections, "sections"));
return self(); return self();
} }
@ -125,7 +134,7 @@ public class CaptureVAppParams extends ParamsType {
private CaptureVAppParams(Builder<?> builder) { private CaptureVAppParams(Builder<?> builder) {
super(builder); super(builder);
this.source = builder.source; this.source = builder.source;
this.sections = builder.sections; this.sections = builder.sections.isEmpty() ? null : ImmutableSet.copyOf(builder.sections);
} }
private CaptureVAppParams() { private CaptureVAppParams() {
@ -138,46 +147,60 @@ public class CaptureVAppParams extends ParamsType {
@XmlElement(name = "Source", required = true) @XmlElement(name = "Source", required = true)
protected Reference source; protected Reference source;
@XmlElementRef @XmlElementRefs({
protected Set<? extends SectionType> sections = Sets.newLinkedHashSet(); @XmlElementRef(type = VirtualHardwareSection.class),
@XmlElementRef(type = LeaseSettingsSection.class),
// @XmlElementRef(type = EulaSection.class),
@XmlElementRef(type = RuntimeInfoSection.class),
// @XmlElementRef(type = AnnotationSection.class),
@XmlElementRef(type = DeploymentOptionSection.class),
@XmlElementRef(type = StartupSection.class),
// @XmlElementRef(type = ResourceAllocationSection.class),
@XmlElementRef(type = NetworkConnectionSection.class),
@XmlElementRef(type = CustomizationSection.class),
@XmlElementRef(type = ProductSection.class),
@XmlElementRef(type = GuestCustomizationSection.class),
@XmlElementRef(type = OperatingSystemSection.class),
@XmlElementRef(type = NetworkConfigSection.class),
@XmlElementRef(type = NetworkSection.class),
// @XmlElementRef(type = InstallSection.class),
@XmlElementRef(type = DiskSection.class)
})
protected Set<SectionType> sections = Sets.newLinkedHashSet();
/** /**
* Gets the value of the source property. * Gets the value of the source property.
*
* @return possible object is
* {@link Reference }
*/ */
public Reference getSource() { public Reference getSource() {
return source; return source;
} }
/** /**
* An ovf:Section to configure the captured vAppTemplate. * An {@code ovf:Section} to configure the captured vAppTemplate.
* *
* Gets the value of the section property. * Objects of the following type(s) are allowed in the list:
* * <ul>
* Objects of the following type(s) are allowed in the list * <li>{@link VirtualHardwareSectionType}
* {@link SectionType } * <li>{@link LeaseSettingsSectionType}
* {@link VirtualHardwareSection } * <li>{@link EulaSectionType}
* {@link LeaseSettingsSection } * <li>{@link RuntimeInfoSectionType}
* {@link EulaSection } * <li>{@link AnnotationSectionType}
* {@link RuntimeInfoSection } * <li>{@link DeploymentOptionSectionType}
* {@link AnnotationSection } * <li>{@link StartupSectionType}
* {@link DeploymentOptionSection } * <li>{@link ResourceAllocationSectionType}
* {@link StartupSection } * <li>{@link NetworkConnectionSectionType}
* {@link ResourceAllocationSection } * <li>{@link CustomizationSectionType}
* {@link NetworkConnectionSection } * <li>{@link ProductSectionType}
* {@link CustomizationSection } * <li>{@link GuestCustomizationSectionType}
* {@link ProductSection } * <li>{@link OperatingSystemSectionType}
* {@link GuestCustomizationSection } * <li>{@link NetworkConfigSectionType}
* {@link OperatingSystemSection } * <li>{@link NetworkSectionType}
* {@link NetworkConfigSection } * <li>{@link DiskSectionType}
* {@link NetworkSection } * <li>{@link InstallSectionType}
* {@link DiskSection } * </ul>
* {@link InstallSection }
*/ */
public Set<? extends SectionType> getSections() { public Set<SectionType> getSections() {
return Collections.unmodifiableSet(this.sections); return sections != null ? ImmutableSet.copyOf(sections) : Collections.<SectionType>emptySet();
} }
@Override @Override
@ -187,8 +210,8 @@ public class CaptureVAppParams extends ParamsType {
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
CaptureVAppParams that = CaptureVAppParams.class.cast(o); CaptureVAppParams that = CaptureVAppParams.class.cast(o);
return equal(source, that.source) && return equal(source, that.source)
equal(sections, that.sections); && equal(sections, that.sections);
} }
@Override @Override

View File

@ -21,20 +21,31 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import org.jclouds.dmtf.ovf.DeploymentOptionSection;
import org.jclouds.dmtf.ovf.DiskSection;
import org.jclouds.dmtf.ovf.NetworkSection;
import org.jclouds.dmtf.ovf.OperatingSystemSection;
import org.jclouds.dmtf.ovf.ProductSection;
import org.jclouds.dmtf.ovf.SectionType; import org.jclouds.dmtf.ovf.SectionType;
import org.jclouds.dmtf.ovf.StartupSection;
import org.jclouds.dmtf.ovf.VirtualHardwareSection;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
* Represents a list of ovf:Section to configure for instantiating a VApp. * Represents a list of {@code ovf:Section} to configure for instantiating a VApp.
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
* @see <a href="http://www.vmware.com/support/vcd/doc/rest-api-doc-1.5-html/types/InstantiationParamsType.html"> * @see <a href="http://www.vmware.com/support/vcd/doc/rest-api-doc-1.5-html/types/InstantiationParamsType.html">
@ -43,7 +54,7 @@ import com.google.common.collect.Sets;
*/ */
@XmlRootElement(name = "InstantiationParams") @XmlRootElement(name = "InstantiationParams")
@XmlType(name = "InstantiationParamsType") @XmlType(name = "InstantiationParamsType")
public class InstantiationParams { public class InstantiationParams implements Set<SectionType> {
public static Builder builder() { public static Builder builder() {
return new Builder(); return new Builder();
@ -87,18 +98,35 @@ public class InstantiationParams {
} }
private InstantiationParams(Set<? extends SectionType> sections) { private InstantiationParams(Set<? extends SectionType> sections) {
this.sections = ImmutableSet.copyOf(sections); this.sections = sections.isEmpty() ? null : ImmutableSet.copyOf(sections);
} }
@XmlElementRef @XmlElementRefs({
protected Set<? extends SectionType> sections = Sets.newLinkedHashSet(); @XmlElementRef(type = VirtualHardwareSection.class),
@XmlElementRef(type = LeaseSettingsSection.class),
// @XmlElementRef(type = EulaSection.class),
@XmlElementRef(type = RuntimeInfoSection.class),
// @XmlElementRef(type = AnnotationSection.class),
@XmlElementRef(type = DeploymentOptionSection.class),
@XmlElementRef(type = StartupSection.class),
// @XmlElementRef(type = ResourceAllocationSection.class),
@XmlElementRef(type = NetworkConnectionSection.class),
@XmlElementRef(type = CustomizationSection.class),
@XmlElementRef(type = ProductSection.class),
@XmlElementRef(type = GuestCustomizationSection.class),
@XmlElementRef(type = OperatingSystemSection.class),
@XmlElementRef(type = NetworkConfigSection.class),
@XmlElementRef(type = NetworkSection.class),
// @XmlElementRef(type = InstallSection.class),
@XmlElementRef(type = DiskSection.class)
})
protected Set<SectionType> sections = Sets.newLinkedHashSet();
/** /**
* An {@code ovf:Section} to configure for instantiation. * An {@code ovf:Section} to configure for instantiation.
* *
* Objects of the following type(s) are allowed in the list * Objects of the following type(s) are allowed in the list:
* <ul> * <ul>
* <li>{@link SectionType}
* <li>{@link VirtualHardwareSection} * <li>{@link VirtualHardwareSection}
* <li>{@link LeaseSettingsSection} * <li>{@link LeaseSettingsSection}
* <li>{@link EulaSection} * <li>{@link EulaSection}
@ -118,8 +146,8 @@ public class InstantiationParams {
* <li>{@link InstallSection} * <li>{@link InstallSection}
* </ul> * </ul>
*/ */
public Set<? extends SectionType> getSections() { public Set<SectionType> getSections() {
return sections; return sections != null ? ImmutableSet.copyOf(sections) : Collections.<SectionType>emptySet();
} }
@Override @Override
@ -141,4 +169,81 @@ public class InstantiationParams {
public String toString() { public String toString() {
return Objects.toStringHelper("").add("sections", sections).toString(); return Objects.toStringHelper("").add("sections", sections).toString();
} }
/**
* The delegate always returns a {@link Set} even if {@link #sections} is {@literal null}.
*
* The delegated {@link Set} is used by the methods implementing its interface.
* <p>
* NOTE Annoying lack of multiple inheritance for using ForwardingList!
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private Set<SectionType> delegate() {
return (Set) getSections();
}
@Override
public boolean add(SectionType arg0) {
return delegate().add(arg0);
}
@Override
public boolean addAll(Collection<? extends SectionType> arg0) {
return delegate().addAll(arg0);
}
@Override
public void clear() {
delegate().clear();
}
@Override
public boolean contains(Object arg0) {
return delegate().contains(arg0);
}
@Override
public boolean containsAll(Collection<?> arg0) {
return delegate().containsAll(arg0);
}
@Override
public boolean isEmpty() {
return delegate().isEmpty();
}
@Override
public Iterator<SectionType> iterator() {
return delegate().iterator();
}
@Override
public boolean remove(Object arg0) {
return delegate().remove(arg0);
}
@Override
public boolean removeAll(Collection<?> arg0) {
return delegate().removeAll(arg0);
}
@Override
public boolean retainAll(Collection<?> arg0) {
return delegate().retainAll(arg0);
}
@Override
public int size() {
return delegate().size();
}
@Override
public Object[] toArray() {
return delegate().toArray();
}
@Override
public <T> T[] toArray(T[] arg0) {
return delegate().toArray(arg0);
}
} }

View File

@ -28,8 +28,8 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs; import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import org.jclouds.dmtf.ovf.DeploymentOptionSection; import org.jclouds.dmtf.ovf.DeploymentOptionSection;
import org.jclouds.dmtf.ovf.DiskSection; import org.jclouds.dmtf.ovf.DiskSection;
@ -69,7 +69,7 @@ public class VAppTemplate extends ResourceEntityType {
public static abstract class Builder<B extends Builder<B>> extends ResourceEntityType.Builder<B> { public static abstract class Builder<B extends Builder<B>> extends ResourceEntityType.Builder<B> {
private Owner owner; private Owner owner;
private Set<VAppTemplate> children = Sets.newLinkedHashSet(); private Set<VAppTemplate> children = Sets.newLinkedHashSet();
private Set<? extends SectionType> sections = Sets.newLinkedHashSet(); private Set<SectionType> sections = Sets.newLinkedHashSet();
private String vAppScopedLocalId; private String vAppScopedLocalId;
private Boolean ovfDescriptorUploaded; private Boolean ovfDescriptorUploaded;
private Boolean goldMaster; private Boolean goldMaster;
@ -85,16 +85,16 @@ public class VAppTemplate extends ResourceEntityType {
/** /**
* @see VAppTemplate#getChildren() * @see VAppTemplate#getChildren()
*/ */
public B children(Set<VAppTemplate> children) { public B children(Iterable<VAppTemplate> children) {
this.children = checkNotNull(children, "children"); this.children = Sets.newLinkedHashSet(checkNotNull(children, "children"));
return self(); return self();
} }
/** /**
* @see VAppTemplate#getSections() * @see VAppTemplate#getSections()
*/ */
public B sections(Set<? extends SectionType> sections) { public B sections(Iterable<? extends SectionType> sections) {
this.sections = checkNotNull(sections, "sections"); this.sections = Sets.newLinkedHashSet(checkNotNull(sections, "sections"));
return self(); return self();
} }
@ -140,10 +140,10 @@ public class VAppTemplate extends ResourceEntityType {
@XmlElement(name = "Owner") @XmlElement(name = "Owner")
private Owner owner; private Owner owner;
@XmlElement(name = "Children") @XmlElementWrapper(name = "Children")
private VAppTemplateChildren children = VAppTemplateChildren.builder().build(); @XmlElement(name = "Vm")
private Set<VAppTemplate> children = Sets.newLinkedHashSet();
@XmlElementRefs({ @XmlElementRefs({
@XmlElementRef(type = SectionType.class),
@XmlElementRef(type = VirtualHardwareSection.class), @XmlElementRef(type = VirtualHardwareSection.class),
@XmlElementRef(type = LeaseSettingsSection.class), @XmlElementRef(type = LeaseSettingsSection.class),
// @XmlElementRef(type = EulaSection.class), // @XmlElementRef(type = EulaSection.class),
@ -162,7 +162,7 @@ public class VAppTemplate extends ResourceEntityType {
// @XmlElementRef(type = InstallSection.class), // @XmlElementRef(type = InstallSection.class),
@XmlElementRef(type = DiskSection.class) @XmlElementRef(type = DiskSection.class)
}) })
private Set<? extends SectionType> sections = Sets.newLinkedHashSet(); private Set<SectionType> sections = Sets.newLinkedHashSet();
@XmlElement(name = "VAppScopedLocalId") @XmlElement(name = "VAppScopedLocalId")
private String vAppScopedLocalId; private String vAppScopedLocalId;
@XmlAttribute @XmlAttribute
@ -173,8 +173,8 @@ public class VAppTemplate extends ResourceEntityType {
protected VAppTemplate(Builder<?> builder) { protected VAppTemplate(Builder<?> builder) {
super(builder); super(builder);
this.owner = builder.owner; this.owner = builder.owner;
this.children = VAppTemplateChildren.builder().vms(builder.children).build(); this.children = builder.children.isEmpty() ? Collections.<VAppTemplate>emptySet() : ImmutableSet.copyOf(builder.children);
this.sections = ImmutableSet.copyOf(builder.sections); this.sections = builder.sections.isEmpty() ? null : ImmutableSet.copyOf(builder.sections);
this.vAppScopedLocalId = builder.vAppScopedLocalId; this.vAppScopedLocalId = builder.vAppScopedLocalId;
this.ovfDescriptorUploaded = builder.ovfDescriptorUploaded; this.ovfDescriptorUploaded = builder.ovfDescriptorUploaded;
this.goldMaster = builder.goldMaster; this.goldMaster = builder.goldMaster;
@ -186,9 +186,6 @@ public class VAppTemplate extends ResourceEntityType {
/** /**
* Gets the value of the owner property. * Gets the value of the owner property.
*
* @return possible object is
* {@link Owner }
*/ */
public Owner getOwner() { public Owner getOwner() {
return owner; return owner;
@ -196,47 +193,41 @@ public class VAppTemplate extends ResourceEntityType {
/** /**
* Gets the value of the children property. * Gets the value of the children property.
*
* @return possible object is
* {@link VAppTemplateChildren }
*/ */
public Set<VAppTemplate> getChildren() { public Set<VAppTemplate> getChildren() {
return children.getVms(); return children;
} }
/** /**
* Contains ovf sections for vApp template. * Contains ovf sections for vApp template.
* Gets the value of the section property. *
* <p/> * Objects of the following type(s) are allowed in the list:
* Objects of the following type(s) are allowed in the list * <ul>
* {@link SectionType } * <li>{@link VirtualHardwareSectionType}
* {@link VirtualHardwareSection } * <li>{@link LeaseSettingsSectionType}
* {@link LeaseSettingsSection } * <li>{@link EulaSectionType}
* {@link EulaSection } * <li>{@link RuntimeInfoSectionType}
* {@link RuntimeInfoSection } * <li>{@link AnnotationSectionType}
* {@link AnnotationSection } * <li>{@link DeploymentOptionSectionType}
* {@link DeploymentOptionSection } * <li>{@link StartupSectionType}
* {@link StartupSection } * <li>{@link ResourceAllocationSectionType}
* {@link ResourceAllocationSection } * <li>{@link NetworkConnectionSectionType}
* {@link NetworkConnectionSection } * <li>{@link CustomizationSectionType}
* {@link CustomizationSection } * <li>{@link ProductSectionType}
* {@link ProductSection } * <li>{@link GuestCustomizationSectionType}
* {@link GuestCustomizationSection } * <li>{@link OperatingSystemSectionType}
* {@link OperatingSystemSection } * <li>{@link NetworkConfigSectionType}
* {@link NetworkConfigSection } * <li>{@link NetworkSectionType}
* {@link NetworkSection } * <li>{@link DiskSectionType}
* {@link DiskSection } * <li>{@link InstallSectionType}
* {@link InstallSection } * </ul>
*/ */
public Set<? extends SectionType> getSections() { public Set<SectionType> getSections() {
return Collections.unmodifiableSet(this.sections); return sections != null ? ImmutableSet.copyOf(sections) : Collections.<SectionType>emptySet();
} }
/** /**
* Gets the value of the vAppScopedLocalId property. * Gets the value of the vAppScopedLocalId property.
*
* @return possible object is
* {@link String }
*/ */
public String getVAppScopedLocalId() { public String getVAppScopedLocalId() {
return vAppScopedLocalId; return vAppScopedLocalId;
@ -244,9 +235,6 @@ public class VAppTemplate extends ResourceEntityType {
/** /**
* Gets the value of the ovfDescriptorUploaded property. * Gets the value of the ovfDescriptorUploaded property.
*
* @return possible object is
* {@link Boolean }
*/ */
public Boolean isOvfDescriptorUploaded() { public Boolean isOvfDescriptorUploaded() {
return ovfDescriptorUploaded; return ovfDescriptorUploaded;
@ -254,9 +242,6 @@ public class VAppTemplate extends ResourceEntityType {
/** /**
* Gets the value of the goldMaster property. * Gets the value of the goldMaster property.
*
* @return possible object is
* {@link Boolean }
*/ */
public boolean isGoldMaster() { public boolean isGoldMaster() {
if (goldMaster == null) { if (goldMaster == null) {

View File

@ -1,132 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
/**
* Represents vApp template children.
* <p/>
* <p/>
* <p>Java class for VAppTemplateChildren complex type.
* <p/>
* <p>The following schema fragment specifies the expected content contained within this class.
* <p/>
* <pre>
* &lt;complexType name="VAppTemplateChildren">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
* &lt;sequence>
* &lt;element name="Vm" type="{http://www.vmware.com/vcloud/v1.5}VAppTemplateType" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*/
@XmlRootElement(name = "Children")
@XmlType(propOrder = {
"vms"
})
public class VAppTemplateChildren {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromVAppTemplateChildren(this);
}
public static class Builder {
private Set<VAppTemplate> vms = Sets.newLinkedHashSet();
/**
* @see VAppTemplateChildren#getVms()
*/
public Builder vms(Set<VAppTemplate> vms) {
this.vms = checkNotNull(vms, "vms");
return this;
}
public VAppTemplateChildren build() {
return new VAppTemplateChildren(vms);
}
public Builder fromVAppTemplateChildren(VAppTemplateChildren in) {
return vms(in.getVms());
}
}
private VAppTemplateChildren(Set<VAppTemplate> vm) {
this.vms = ImmutableSet.copyOf(vm);
}
private VAppTemplateChildren() {
// For JAXB
}
@XmlElement(name = "Vm")
protected Set<VAppTemplate> vms = Sets.newLinkedHashSet();
/**
* Gets the value of the vm property.
*/
public Set<VAppTemplate> getVms() {
return Collections.unmodifiableSet(this.vms);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
VAppTemplateChildren that = VAppTemplateChildren.class.cast(o);
return equal(vms, that.vms);
}
@Override
public int hashCode() {
return Objects.hashCode(vms);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("vms", vms).toString();
}
}

View File

@ -33,6 +33,7 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -68,8 +69,11 @@ import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.VAppNetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.VAppNetworkConfiguration;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest; import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
import org.jclouds.xml.internal.JAXBParser;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
/** /**