From d1b0da081d3182306db9d48584882d0fb9ecc805 Mon Sep 17 00:00:00 2001 From: Adam Lowe Date: Mon, 5 Mar 2012 21:31:51 +0000 Subject: [PATCH] VCloud Director 1.5: making sure collections in domain objects are immutable --- .../v1_5/domain/AvailableNetworks.java | 6 +- .../v1_5/domain/CaptureVAppParams.java | 25 ++------- .../director/v1_5/domain/CatalogItem.java | 3 +- .../director/v1_5/domain/CatalogItems.java | 5 +- .../director/v1_5/domain/CatalogsList.java | 15 ++--- .../v1_5/domain/ComposeVAppParams.java | 48 ++++++---------- .../v1_5/domain/CustomizationSection.java | 3 +- .../director/v1_5/domain/FilesList.java | 3 +- .../domain/GuestCustomizationSection.java | 6 +- .../v1_5/domain/InstantiationParams.java | 19 +------ .../director/v1_5/domain/IpAddresses.java | 5 +- .../vcloud/director/v1_5/domain/IpRanges.java | 4 +- .../v1_5/domain/LeaseSettingsSection.java | 49 +++++----------- .../vcloud/director/v1_5/domain/Metadata.java | 6 +- .../v1_5/domain/NetworkConfigSection.java | 14 ++--- .../v1_5/domain/NetworkConfiguration.java | 17 +++--- .../v1_5/domain/NetworkConnectionSection.java | 15 ++--- .../director/v1_5/domain/NetworkFeatures.java | 20 ++++--- .../vcloud/director/v1_5/domain/OrgList.java | 3 +- .../v1_5/domain/ProductSectionList.java | 26 ++++----- .../director/v1_5/domain/RelocateParams.java | 56 ++++++++++++++++++- .../v1_5/domain/ResourceEntities.java | 5 +- .../director/v1_5/domain/ResourceType.java | 6 +- .../vcloud/director/v1_5/domain/Session.java | 3 +- .../domain/SourcedCompositionItemParam.java | 23 ++------ .../domain/SupportedHardwareVersions.java | 3 +- .../director/v1_5/domain/TasksInProgress.java | 9 +-- .../director/v1_5/domain/TasksList.java | 3 +- .../v1_5/domain/VAppNetworkConfiguration.java | 38 ++++++------- .../cim/ResourceAllocationSettingData.java | 14 ++--- 30 files changed, 218 insertions(+), 234 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java index 4f1bef9acd..8e794289f4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java @@ -23,11 +23,13 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.util.Collection; +import java.util.Collections; import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -98,7 +100,7 @@ public class AvailableNetworks { protected Set networks = Sets.newLinkedHashSet(); private AvailableNetworks(Set networks) { - this.networks = networks; + this.networks = ImmutableSet.copyOf(networks); } private AvailableNetworks() { @@ -109,7 +111,7 @@ public class AvailableNetworks { * Gets the value of the network property. */ public Set getNetworks() { - return this.networks; + return Collections.unmodifiableSet(this.networks); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java index daeb321453..0383672f43 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java @@ -22,6 +22,7 @@ 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.JAXBElement; import javax.xml.bind.annotation.XmlElement; @@ -101,12 +102,10 @@ public class CaptureVAppParams return this; } - public CaptureVAppParams build() { return new CaptureVAppParams(description, name, source, sections); } - @Override public Builder fromParamsType(ParamsType in) { return Builder.class.cast(super.fromParamsType(in)); @@ -133,7 +132,6 @@ public class CaptureVAppParams this.sections = ImmutableSet.copyOf(sections); } - @XmlElement(name = "Source", required = true) protected Reference source; @XmlElementRef @@ -151,22 +149,9 @@ public class CaptureVAppParams /** * An ovf:Section to configure the captured vAppTemplate. - * Gets the value of the section property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the section property. - *

- *

- * For example, to add a new item, do as follows: - *

-    *    getSection().add(newItem);
-    * 
- *

- *

- *

+ * + * Gets the value of the section property. + * * Objects of the following type(s) are allowed in the list * {@link JAXBElement }{@code <}{@link Section> }{@code >} * {@link JAXBElement }{@code <}{@link VirtualHardwareSection > }{@code >} @@ -188,7 +173,7 @@ public class CaptureVAppParams * {@link JAXBElement }{@code <}{@link InstallSection> }{@code >} */ public Set> getSections() { - return this.sections; + return Collections.unmodifiableSet(this.sections); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java index 7720193d3b..db8be1d67a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItem.java @@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; /** @@ -173,7 +174,7 @@ public class CatalogItem extends EntityType { private CatalogItem(URI href, String type, Set links, String description, TasksInProgress tasksInProgress, String id, String name, Reference entity, Set properties) { super(href, type, links, description, tasksInProgress, id, name); this.entity = entity; - this.properties = properties; + this.properties = ImmutableSet.copyOf(properties); } private CatalogItem() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java index 15b42492b3..6e0a09cff1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogItems.java @@ -32,6 +32,7 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; /** @@ -86,11 +87,11 @@ public class CatalogItems { } private CatalogItems() { - // For JAXB and builder use + // For JAXB } private CatalogItems(Set catalogItems) { - this.catalogItems = catalogItems; + this.catalogItems = ImmutableSet.copyOf(catalogItems); } @XmlElement(name = "CatalogItem") diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java index 4571917f6b..bf023faf13 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogsList.java @@ -22,6 +22,7 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.util.Collection; +import java.util.Collections; import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -62,16 +63,8 @@ public class CatalogsList { /** * @see CatalogsList#getCatalogItems() */ - public Builder catalogs(Collection catalogReferences) { - this.catalogReferences = Sets.newLinkedHashSet(checkNotNull(catalogReferences, "catalogReferences")); - return this; - } - - /** - * @see CatalogsList#getCatalogItems() - */ - public Builder catalog(Reference catalog) { - this.catalogReferences.add(checkNotNull(catalog, "catalog")); + public Builder catalogs(Set catalogReferences) { + this.catalogReferences = checkNotNull(catalogReferences, "catalogReferences"); return this; } @@ -99,7 +92,7 @@ public class CatalogsList { * Gets the value of the catalogReferences property. */ public Set getCatalogItems() { - return this.catalogReferences; + return Collections.unmodifiableSet(this.catalogReferences); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java index e9ebb23274..ee3a4574fc 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java @@ -22,6 +22,7 @@ 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.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -57,7 +58,7 @@ import com.google.common.collect.Sets; * */ @XmlType(name = "ComposeVAppParams", propOrder = { - "sourcedItem", + "sourcedItems", "allEULAsAccepted" }) @XmlSeeAlso({ @@ -78,15 +79,15 @@ public class ComposeVAppParams public static class Builder extends VAppCreationParamsType.Builder { - private Set sourcedItem = Sets.newLinkedHashSet(); + private Set sourcedItems = Sets.newLinkedHashSet(); private Boolean allEULAsAccepted; private Boolean linkedClone; /** - * @see ComposeVAppParams#getSourcedItem() + * @see ComposeVAppParams#getSourcedItems() */ - public Builder sourcedItem(Set sourcedItem) { - this.sourcedItem = checkNotNull(sourcedItem, "sourcedItem"); + public Builder sourcedItems(Set sourcedItems) { + this.sourcedItems = checkNotNull(sourcedItems, "sourcedItems"); return this; } @@ -109,7 +110,7 @@ public class ComposeVAppParams public ComposeVAppParams build() { return new ComposeVAppParams(description, name, vAppParent, instantiationParams, deploy, powerOn, - sourcedItem, allEULAsAccepted, linkedClone); + sourcedItems, allEULAsAccepted, linkedClone); } @@ -120,16 +121,16 @@ public class ComposeVAppParams public Builder fromComposeVAppParams(ComposeVAppParams in) { return fromVAppCreationParamsType(in) - .sourcedItem(in.getSourcedItem()) + .sourcedItems(in.getSourcedItems()) .allEULAsAccepted(in.isAllEULAsAccepted()) .linkedClone(in.isLinkedClone()); } } public ComposeVAppParams(String description, String name, Reference vAppParent, InstantiationParams instantiationParams, - Boolean deploy, Boolean powerOn, Set sourcedItem, Boolean allEULAsAccepted, Boolean linkedClone) { + Boolean deploy, Boolean powerOn, Set sourcedItems, Boolean allEULAsAccepted, Boolean linkedClone) { super(description, name, vAppParent, instantiationParams, deploy, powerOn); - this.sourcedItem = ImmutableSet.copyOf(sourcedItem); + this.sourcedItems = ImmutableSet.copyOf(sourcedItems); this.allEULAsAccepted = allEULAsAccepted; this.linkedClone = linkedClone; } @@ -140,7 +141,7 @@ public class ComposeVAppParams @XmlElement(name = "SourcedItem") - protected Set sourcedItem = Sets.newLinkedHashSet(); + protected Set sourcedItems = Sets.newLinkedHashSet(); @XmlElement(name = "AllEULAsAccepted") protected Boolean allEULAsAccepted; @XmlAttribute @@ -148,26 +149,9 @@ public class ComposeVAppParams /** * Gets the value of the sourcedItem property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the sourcedItem property. - *

- *

- * For example, to add a new item, do as follows: - *

-    *    getSourcedItem().add(newItem);
-    * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link SourcedCompositionItemParam } */ - public Set getSourcedItem() { - return this.sourcedItem; + public Set getSourcedItems() { + return Collections.unmodifiableSet(this.sourcedItems); } /** @@ -201,14 +185,14 @@ public class ComposeVAppParams if (o == null || getClass() != o.getClass()) return false; ComposeVAppParams that = ComposeVAppParams.class.cast(o); - return equal(sourcedItem, that.sourcedItem) && + return equal(sourcedItems, that.sourcedItems) && equal(allEULAsAccepted, that.allEULAsAccepted) && equal(linkedClone, that.linkedClone); } @Override public int hashCode() { - return Objects.hashCode(sourcedItem, + return Objects.hashCode(sourcedItems, allEULAsAccepted, linkedClone); } @@ -216,7 +200,7 @@ public class ComposeVAppParams @Override public String toString() { return Objects.toStringHelper("") - .add("sourcedItem", sourcedItem) + .add("sourcedItem", sourcedItems) .add("allEULAsAccepted", allEULAsAccepted) .add("linkedClone", linkedClone).toString(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java index 6e0b618691..9081103582 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CustomizationSection.java @@ -23,6 +23,7 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.Collections; import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -187,7 +188,7 @@ public class CustomizationSection extends SectionType { * Gets the value of the links property. */ public Set getLinks() { - return this.links; + return Collections.unmodifiableSet(this.links); } /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java index 233e132923..4993ac68b6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/FilesList.java @@ -22,6 +22,7 @@ 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.List; import javax.xml.bind.annotation.XmlElement; @@ -112,7 +113,7 @@ public class FilesList { * Gets the value of the file property. */ public List getFiles() { - return this.files; + return Collections.unmodifiableList(this.files); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java index e10406e68f..4a355a029a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/GuestCustomizationSection.java @@ -237,7 +237,7 @@ public class GuestCustomizationSection extends SectionType links) { this.links = checkNotNull(links, "links"); @@ -285,7 +285,7 @@ public class GuestCustomizationSection extends SectionType getLink() { + public Set getLinks() { return Collections.unmodifiableSet(this.links); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java index 6154a70e67..53bb6755e6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java @@ -23,6 +23,7 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Set; import javax.xml.bind.JAXBElement; @@ -105,7 +106,7 @@ public class InstantiationParams { } - @XmlElementRef(name = "Section", namespace = "http://schemas.dmtf.org/ovf/envelope/1", type = JAXBElement.class) + @XmlElementRef protected Set> sections = Sets.newLinkedHashSet(); /** @@ -113,20 +114,6 @@ public class InstantiationParams { *

* Gets the value of the section property. *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the section property. - *

- *

- * For example, to add a new item, do as follows: - *

-    *    getSection().add(newItem);
-    * 
- *

- *

- *

* Objects of the following type(s) are allowed in the list * {@link JAXBElement }{@code <}{@link SectionType }{@code >} * {@link JAXBElement }{@code <}{@link VirtualHardwareSection }{@code >} @@ -148,7 +135,7 @@ public class InstantiationParams { * {@link JAXBElement }{@code <}{@link InstallSection }{@code >} */ public Set> getSections() { - return this.sections; + return Collections.unmodifiableSet(this.sections); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java index 0d2d4b1302..c6b2314fd6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java @@ -21,6 +21,7 @@ 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; @@ -52,7 +53,7 @@ public class IpAddresses { * @see IpAddresses#getIpAddresses() */ public Builder ipAddresses(Set ipAddresses) { - this.ipAddresses = Sets.newLinkedHashSet(checkNotNull(ipAddresses, "ipAddresses")); + this.ipAddresses.addAll(checkNotNull(ipAddresses, "ipAddresses")); return this; } @@ -85,7 +86,7 @@ public class IpAddresses { private Set ipAddresses = Sets.newLinkedHashSet(); public Set getIpAddresses() { - return ImmutableSet.copyOf(ipAddresses); + return Collections.unmodifiableSet(ipAddresses); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java index f1dd1b0165..116873b042 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java @@ -21,6 +21,8 @@ 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.LinkedHashSet; import java.util.Set; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; @@ -85,7 +87,7 @@ public class IpRanges { private Set ipRanges = Sets.newLinkedHashSet(); public Set getIpRanges() { - return ImmutableSet.copyOf(ipRanges); + return Collections.unmodifiableSet(ipRanges); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java index 84a905f3a9..314e16405a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/LeaseSettingsSection.java @@ -24,18 +24,20 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Collections; +import java.util.Date; import java.util.Set; + import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; -import javax.xml.datatype.XMLGregorianCalendar; import org.jclouds.javax.annotation.Nullable; import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -88,8 +90,8 @@ public class LeaseSettingsSection extends SectionType { private Set links = Sets.newLinkedHashSet(); private Integer deploymentLeaseInSeconds; private Integer storageLeaseInSeconds; - private XMLGregorianCalendar deploymentLeaseExpiration; - private XMLGregorianCalendar storageLeaseExpiration; + private Date deploymentLeaseExpiration; + private Date storageLeaseExpiration; private URI href; private String type; @@ -120,7 +122,7 @@ public class LeaseSettingsSection extends SectionType { /** * @see LeaseSettingsSection#getDeploymentLeaseExpiration() */ - public Builder deploymentLeaseExpiration(XMLGregorianCalendar deploymentLeaseExpiration) { + public Builder deploymentLeaseExpiration(Date deploymentLeaseExpiration) { this.deploymentLeaseExpiration = deploymentLeaseExpiration; return this; } @@ -128,7 +130,7 @@ public class LeaseSettingsSection extends SectionType { /** * @see LeaseSettingsSection#getStorageLeaseExpiration() */ - public Builder storageLeaseExpiration(XMLGregorianCalendar storageLeaseExpiration) { + public Builder storageLeaseExpiration(Date storageLeaseExpiration) { this.storageLeaseExpiration = storageLeaseExpiration; return this; } @@ -200,10 +202,10 @@ public class LeaseSettingsSection extends SectionType { protected Integer storageLeaseInSeconds; @XmlElement(name = "DeploymentLeaseExpiration") @XmlSchemaType(name = "dateTime") - protected XMLGregorianCalendar deploymentLeaseExpiration; + protected Date deploymentLeaseExpiration; @XmlElement(name = "StorageLeaseExpiration") @XmlSchemaType(name = "dateTime") - protected XMLGregorianCalendar storageLeaseExpiration; + protected Date storageLeaseExpiration; @XmlAttribute @XmlSchemaType(name = "anyURI") protected URI href; @@ -211,10 +213,10 @@ public class LeaseSettingsSection extends SectionType { protected String type; private LeaseSettingsSection(@Nullable String info, @Nullable Boolean required, Set links, Integer deploymentLeaseInSeconds, - Integer storageLeaseInSeconds, XMLGregorianCalendar deploymentLeaseExpiration, - XMLGregorianCalendar storageLeaseExpiration, URI href, String type) { + Integer storageLeaseInSeconds, Date deploymentLeaseExpiration, + Date storageLeaseExpiration, URI href, String type) { super(info, required); - this.links = links; + this.links = ImmutableSet.copyOf(links); this.deploymentLeaseInSeconds = deploymentLeaseInSeconds; this.storageLeaseInSeconds = storageLeaseInSeconds; this.deploymentLeaseExpiration = deploymentLeaseExpiration; @@ -229,23 +231,6 @@ public class LeaseSettingsSection extends SectionType { /** * Gets the value of the link property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the link property. - *

- *

- * For example, to add a new item, do as follows: - *

-    *    getLink().add(newItem);
-    * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link Link } */ public Set getLinks() { return Collections.unmodifiableSet(this.links); @@ -273,21 +258,15 @@ public class LeaseSettingsSection extends SectionType { /** * Gets the value of the deploymentLeaseExpiration property. - * - * @return possible object is - * {@link XMLGregorianCalendar } */ - public XMLGregorianCalendar getDeploymentLeaseExpiration() { + public Date getDeploymentLeaseExpiration() { return deploymentLeaseExpiration; } /** * Gets the value of the storageLeaseExpiration property. - * - * @return possible object is - * {@link XMLGregorianCalendar } */ - public XMLGregorianCalendar getStorageLeaseExpiration() { + public Date getStorageLeaseExpiration() { return storageLeaseExpiration; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java index b0580abca5..781f4b684b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Metadata.java @@ -22,6 +22,7 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.Collections; import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -105,8 +106,7 @@ public class Metadata extends ResourceType { */ @Override public Builder links(Set links) { - super.links(Sets.newLinkedHashSet(checkNotNull(links, "links"))); - return this; + return Builder.class.cast(super.links(links)); } /** @@ -145,7 +145,7 @@ public class Metadata extends ResourceType { private Set metadataEntries = Sets.newLinkedHashSet(); public Set getMetadataEntries() { - return ImmutableSet.copyOf(metadataEntries); + return Collections.unmodifiableSet(metadataEntries); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java index 5397647130..6b90af824d 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfigSection.java @@ -81,7 +81,7 @@ public class NetworkConfigSection extends SectionType { public static class Builder extends SectionType.Builder { private Set links = Sets.newLinkedHashSet(); - private Set> networkConfigs = Sets.newLinkedHashSet(); + private Set networkConfigs = Sets.newLinkedHashSet(); private URI href; private String type; @@ -96,7 +96,7 @@ public class NetworkConfigSection extends SectionType { /** * @see NetworkConfigSection#getNetworkConfigs() */ - public Builder networkConfig(Set> networkConfigs) { + public Builder networkConfigs(Set networkConfigs) { this.networkConfigs = checkNotNull(networkConfigs, "networkConfigs"); return this; } @@ -125,7 +125,7 @@ public class NetworkConfigSection extends SectionType { public Builder fromNetworkConfigSection(NetworkConfigSection in) { return fromSection(in) .links(in.getLinks()) - .networkConfig(in.getNetworkConfigs()) + .networkConfigs(in.getNetworkConfigs()) .href(in.getHref()) .type(in.getType()); } @@ -157,16 +157,16 @@ public class NetworkConfigSection extends SectionType { } @XmlElement(name = "Link") - protected Set links; + protected Set links = Sets.newLinkedHashSet(); @XmlElement(name = "NetworkConfig") - protected Set> networkConfigs; + protected Set networkConfigs = Sets.newLinkedHashSet(); @XmlAttribute @XmlSchemaType(name = "anyURI") protected URI href; @XmlAttribute protected String type; - public NetworkConfigSection(@Nullable String info, @Nullable Boolean required, Set links, Set> networkConfigs, + public NetworkConfigSection(@Nullable String info, @Nullable Boolean required, Set links, Set networkConfigs, URI href, String type) { super(info, required); this.links = ImmutableSet.copyOf(links); @@ -189,7 +189,7 @@ public class NetworkConfigSection extends SectionType { /** * Gets the value of the networkConfig property. */ - public Set> getNetworkConfigs() { + public Set getNetworkConfigs() { return Collections.unmodifiableSet(this.networkConfigs); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java index 5b623ccef7..5d7caedda8 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java @@ -44,9 +44,9 @@ public class NetworkConfiguration { public static class Builder { private IpScope ipScope; - private ReferenceType parentNetwork; + private Reference parentNetwork; private String fenceMode; - private boolean retainNetInfoAcrossDeployments; + private Boolean retainNetInfoAcrossDeployments; private NetworkFeatures features; private SyslogServerSettings syslogServerSettings; private RouterInfo routerInfo; @@ -62,7 +62,7 @@ public class NetworkConfiguration { /** * @see NetworkConfiguration#getParentNetwork() */ - public Builder parentNetwork(ReferenceType parentNetwork) { + public Builder parentNetwork(Reference parentNetwork) { this.parentNetwork = parentNetwork; return this; } @@ -120,7 +120,7 @@ public class NetworkConfiguration { } } - public NetworkConfiguration(IpScope ipScope, ReferenceType parentNetwork, String fenceMode, boolean retainNetInfoAcrossDeployments, + public NetworkConfiguration(IpScope ipScope, Reference parentNetwork, String fenceMode, Boolean retainNetInfoAcrossDeployments, NetworkFeatures features, SyslogServerSettings syslogServerSettings, RouterInfo routerInfo) { this.ipScope = ipScope; this.parentNetwork = parentNetwork; @@ -138,11 +138,11 @@ public class NetworkConfiguration { @XmlElement(name = "IpScope") private IpScope ipScope; @XmlElement(name = "ParentNetwork") - private ReferenceType parentNetwork; + private Reference parentNetwork; @XmlElement(name = "FenceMode") private String fenceMode; @XmlElement(name = "RetainNetInfoAcrossDeployments") - private boolean retainNetInfoAcrossDeployments = false; + private Boolean retainNetInfoAcrossDeployments; @XmlElement(name = "Features") private NetworkFeatures features; @XmlElement(name = "SyslogServerSettings") @@ -162,7 +162,7 @@ public class NetworkConfiguration { /** * @return reference to parent network. */ - public ReferenceType getParentNetwork() { + public Reference getParentNetwork() { return parentNetwork; } @@ -212,7 +212,8 @@ public class NetworkConfiguration { if (o == null || getClass() != o.getClass()) return false; NetworkConfiguration that = NetworkConfiguration.class.cast(o); - return equal(ipScope, that.ipScope) && equal(parentNetwork, that.parentNetwork) && + return equal(ipScope, that.ipScope) && + equal(parentNetwork, that.parentNetwork) && equal(fenceMode, that.fenceMode) && equal(retainNetInfoAcrossDeployments, that.retainNetInfoAcrossDeployments) && equal(features, that.features) && diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java index ce7d5b535e..63431c526b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConnectionSection.java @@ -23,6 +23,7 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.Collections; import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -83,7 +84,7 @@ public class NetworkConnectionSection extends SectionType { private Integer primaryNetworkConnectionIndex; - private Set networkConnection = Sets.newLinkedHashSet(); + private Set networkConnections = Sets.newLinkedHashSet(); private Set links = Sets.newLinkedHashSet(); private URI href; private String type; @@ -99,8 +100,8 @@ public class NetworkConnectionSection extends SectionType networkConnection) { - this.networkConnection = checkNotNull(networkConnection, "networkConnection"); + public Builder networkConnections(Set networkConnections) { + this.networkConnections = checkNotNull(networkConnections, "networkConnection"); return this; } @@ -130,14 +131,14 @@ public class NetworkConnectionSection extends SectionType getNetworkConnections() { - return this.networkConnections; + return Collections.unmodifiableSet(this.networkConnections); } /** @@ -222,7 +223,7 @@ public class NetworkConnectionSection extends SectionType getLinks() { - return this.links; + return Collections.unmodifiableSet(this.links); } /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java index e8b3c3ffed..b4b0220ac1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java @@ -21,8 +21,10 @@ 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.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; import com.google.common.base.Objects; @@ -47,12 +49,12 @@ public class NetworkFeatures { public static class Builder { - private Set services = Sets.newLinkedHashSet(); + private Set services = Sets.newLinkedHashSet(); /** * @see NetworkFeatures#getNetworkServices() */ - public Builder services(Set services) { + public Builder services(Set services) { this.services = Sets.newLinkedHashSet(checkNotNull(services, "services")); return this; } @@ -60,7 +62,7 @@ public class NetworkFeatures { /** * @see NetworkFeatures#getNetworkServices() */ - public Builder service(NetworkService service) { + public Builder service(NetworkServiceType service) { services.add(checkNotNull(service, "service")); return this; } @@ -78,19 +80,19 @@ public class NetworkFeatures { // For JAXB and builder use } - public NetworkFeatures(Set services) { - this.services = services; + public NetworkFeatures(Set services) { + this.services = ImmutableSet.copyOf(services); } - @XmlElement(name = "NetworkService") - private Set services = Sets.newLinkedHashSet(); + @XmlElementRef + private Set services = Sets.newLinkedHashSet(); /** * @return a Network service. May be any of DhcpService, NatService, IpsecVpnService, * DhcpService, or StaticRoutingService. */ - public Set getNetworkServices() { - return ImmutableSet.copyOf(services); + public Set getNetworkServices() { + return Collections.unmodifiableSet(services); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java index 1c74e8bace..5b107602e6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgList.java @@ -21,6 +21,7 @@ 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; @@ -90,7 +91,7 @@ public class OrgList { private Set orgs = Sets.newLinkedHashSet(); public Set getOrgs() { - return ImmutableSet.copyOf(orgs); + return Collections.unmodifiableSet(orgs); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java index d5cd569e17..7deb414781 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ProductSectionList.java @@ -23,6 +23,7 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.Collections; import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; @@ -55,7 +56,7 @@ import com.google.common.collect.Sets; * */ @XmlType(name = "ProductSectionList", propOrder = { - "productSection" + "productSections" }) public class ProductSectionList extends ResourceType @@ -76,9 +77,9 @@ public class ProductSectionList private Set productSections = Sets.newLinkedHashSet(); /** - * @see ProductSectionList#getProductSection() + * @see ProductSectionList#getProductSections() */ - public Builder productSection(Set productSections) { + public Builder productSections(Set productSections) { this.productSections = checkNotNull(productSections, "productSection"); return this; } @@ -89,7 +90,6 @@ public class ProductSectionList return productSectionList; } - /** * @see ResourceType#getHref() */ @@ -134,7 +134,7 @@ public class ProductSectionList public Builder fromProductSectionList(ProductSectionList in) { return fromResourceType(in) - .productSection(in.getProductSection()); + .productSections(in.getProductSections()); } } @@ -142,19 +142,19 @@ public class ProductSectionList // For JAXB and builder use } - private ProductSectionList(Set productSection) { - this.productSection = ImmutableSet.copyOf(productSection); + private ProductSectionList(Set productSections) { + this.productSections = ImmutableSet.copyOf(productSections); } @XmlElement(name = "ProductSection", namespace = "http://schemas.dmtf.org/ovf/envelope/1") - protected Set productSection = Sets.newLinkedHashSet(); + protected Set productSections = Sets.newLinkedHashSet(); /** * Gets the value of the productSection property. */ - public Set getProductSection() { - return this.productSection; + public Set getProductSections() { + return Collections.unmodifiableSet(this.productSections); } @Override @@ -164,18 +164,18 @@ public class ProductSectionList if (o == null || getClass() != o.getClass()) return false; ProductSectionList that = ProductSectionList.class.cast(o); - return equal(productSection, that.productSection); + return equal(productSections, that.productSections); } @Override public int hashCode() { - return Objects.hashCode(productSection); + return Objects.hashCode(productSections); } @Override public String toString() { return Objects.toStringHelper("") - .add("productSection", productSection).toString(); + .add("productSections", productSections).toString(); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RelocateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RelocateParams.java index aeb036e2c5..6573febef1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RelocateParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RelocateParams.java @@ -19,9 +19,15 @@ 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 javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import com.google.common.base.Objects; + /** * Parameters to be used for vm relocation. @@ -43,13 +49,38 @@ import javax.xml.bind.annotation.XmlType; * </complexType> * */ -@XmlType(name = "RelocateParams", propOrder = { +@XmlRootElement(name = "RelocateParams") +@XmlType(propOrder = { "datastore" }) public class RelocateParams { + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private Reference datastore; + + public Builder datastore(Reference dataStore) { + this.datastore = dataStore; + return this; + } + + public RelocateParams build() { + return new RelocateParams(datastore); + } + } @XmlElement(name = "Datastore", required = true) - protected ReferenceType datastore; + private Reference datastore; + + private RelocateParams(Reference datastore) { + this.datastore = checkNotNull(datastore); + } + + private RelocateParams() { + // for JAXB + } /** * Gets the value of the datastore property. @@ -60,4 +91,25 @@ public class RelocateParams { public ReferenceType getDatastore() { return datastore; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RelocateParams that = RelocateParams.class.cast(o); + return equal(datastore, that.datastore); + } + + @Override + public int hashCode() { + return Objects.hashCode(datastore); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("datastore", datastore).toString(); + } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java index 6bcf21db4d..f45870831a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java @@ -22,6 +22,7 @@ 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.XmlType; @@ -72,7 +73,7 @@ public class ResourceEntities { * @see ResourceEntities#getResourceEntities() */ public Builder resourceEntities(Set resourceEntities) { - this.resourceEntities = checkNotNull(resourceEntities, "resourceEntities"); + this.resourceEntities = Sets.newLinkedHashSet(checkNotNull(resourceEntities, "resourceEntities")); return this; } @@ -110,7 +111,7 @@ public class ResourceEntities { * Gets the value of the resourceEntity property. */ public Set getResourceEntities() { - return this.resourceEntities; + return Collections.unmodifiableSet(this.resourceEntities); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java index b90944e3b4..3574c29f12 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceType.java @@ -22,12 +22,14 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.Collections; import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; /** @@ -100,7 +102,7 @@ public abstract class ResourceType> implements URISupp protected ResourceType(URI href, String type, Set links) { this.href = href; this.type = type; - this.links = links; + this.links = ImmutableSet.copyOf(links); } protected ResourceType() { @@ -148,7 +150,7 @@ public abstract class ResourceType> implements URISupp * Set of optional links to an entity or operation associated with this object. */ public Set getLinks() { - return links; + return Collections.unmodifiableSet(links); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java index e72bd5797e..a03d3d58a9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Session.java @@ -22,6 +22,7 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.Collections; import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -129,7 +130,7 @@ public class Session { private URI href; public Set getLinks() { - return ImmutableSet.copyOf(links); + return Collections.unmodifiableSet(links); } /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java index d699a9096f..f1b7d41cbd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java @@ -20,7 +20,9 @@ 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.XmlAttribute; import javax.xml.bind.annotation.XmlElement; @@ -107,7 +109,7 @@ public class SourcedCompositionItemParam { * @see SourcedCompositionItemParam#getNetworkAssignments() */ public Builder networkAssignments(Set networkAssignments) { - this.networkAssignments = networkAssignments; + this.networkAssignments = checkNotNull(networkAssignments, "networkAssignments"); return this; } @@ -189,26 +191,9 @@ public class SourcedCompositionItemParam { /** * Gets the value of the networkAssignment property. - *

- *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the networkAssignment property. - *

- *

- * For example, to add a new item, do as follows: - *

-    *    getNetworkAssignment().add(newItem);
-    * 
- *

- *

- *

- * Objects of the following type(s) are allowed in the list - * {@link NetworkAssignment } */ public Set getNetworkAssignments() { - return this.networkAssignments; + return Collections.unmodifiableSet(this.networkAssignments); } /** diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java index e74dea141f..41c3ee484f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java @@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -100,7 +101,7 @@ public class SupportedHardwareVersions { } private SupportedHardwareVersions(Set supportedHardwareVersions) { - this.supportedHardwareVersions = supportedHardwareVersions; + this.supportedHardwareVersions = ImmutableSet.copyOf(supportedHardwareVersions); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java index b3fe5b4d28..6ac91c6d17 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksInProgress.java @@ -22,6 +22,7 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.util.Collection; +import java.util.Collections; import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -52,7 +53,7 @@ public class TasksInProgress { * @see TasksInProgress#getTasks() */ public Builder tasks(Set tasks) { - this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks")); + this.tasks = checkNotNull(tasks, "tasks"); return this; } @@ -73,11 +74,11 @@ public class TasksInProgress { } } - protected TasksInProgress() { + private TasksInProgress() { // For JAXB and builder use } - protected TasksInProgress(Collection tasks) { + private TasksInProgress(Collection tasks) { this.tasks = ImmutableSet.copyOf(tasks); } @@ -85,7 +86,7 @@ public class TasksInProgress { private Set tasks = Sets.newLinkedHashSet(); public Set getTasks() { - return ImmutableSet.copyOf(tasks); + return Collections.unmodifiableSet(tasks); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java index 93a366277e..dc3069972a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/TasksList.java @@ -22,6 +22,7 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; +import java.util.Collections; import java.util.Set; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -172,7 +173,7 @@ public class TasksList extends EntityType { private Set tasks = Sets.newLinkedHashSet(); public Set getTasks() { - return ImmutableSet.copyOf(tasks); + return Collections.unmodifiableSet(tasks); } @Override diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java index 8cbb058911..14842b705b 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppNetworkConfiguration.java @@ -61,17 +61,17 @@ import com.google.common.collect.Sets; "configuration", "isDeployed" }) -public class VAppNetworkConfiguration> extends ResourceType { - public static > Builder builder() { - return new Builder(); +public class VAppNetworkConfiguration extends ResourceType { + public static Builder builder() { + return new Builder(); } @Override - public Builder toBuilder() { - return new Builder().fromVAppNetworkConfiguration(this); + public Builder toBuilder() { + return new Builder().fromVAppNetworkConfiguration(this); } - public static class Builder> extends ResourceType.Builder { + public static class Builder extends ResourceType.Builder { private String description; private NetworkConfiguration configuration; @@ -81,7 +81,7 @@ public class VAppNetworkConfiguration> ext /** * @see VAppNetworkConfiguration#getDescription() */ - public Builder description(String description) { + public Builder description(String description) { this.description = description; return this; } @@ -89,7 +89,7 @@ public class VAppNetworkConfiguration> ext /** * @see VAppNetworkConfiguration#getConfiguration() */ - public Builder configuration(NetworkConfiguration configuration) { + public Builder configuration(NetworkConfiguration configuration) { this.configuration = configuration; return this; } @@ -97,7 +97,7 @@ public class VAppNetworkConfiguration> ext /** * @see VAppNetworkConfiguration#isDeployed() */ - public Builder isDeployed(Boolean isDeployed) { + public Builder isDeployed(Boolean isDeployed) { this.isDeployed = isDeployed; return this; } @@ -105,14 +105,14 @@ public class VAppNetworkConfiguration> ext /** * @see VAppNetworkConfiguration#getNetworkName() */ - public Builder networkName(String networkName) { + public Builder networkName(String networkName) { this.networkName = networkName; return this; } - public VAppNetworkConfiguration build() { - return new VAppNetworkConfiguration(href, type, links, + public VAppNetworkConfiguration build() { + return new VAppNetworkConfiguration(href, type, links, description, configuration, isDeployed, networkName); } @@ -121,7 +121,7 @@ public class VAppNetworkConfiguration> ext * @see ResourceType#getHref() */ @Override - public Builder href(URI href) { + public Builder href(URI href) { super.href(href); return this; } @@ -130,7 +130,7 @@ public class VAppNetworkConfiguration> ext * @see ResourceType#getType() */ @Override - public Builder type(String type) { + public Builder type(String type) { super.type(type); return this; } @@ -139,7 +139,7 @@ public class VAppNetworkConfiguration> ext * @see ResourceType#getLinks() */ @Override - public Builder links(Set links) { + public Builder links(Set links) { super.links(Sets.newLinkedHashSet(checkNotNull(links, "links"))); return this; } @@ -148,7 +148,7 @@ public class VAppNetworkConfiguration> ext * @see ResourceType#getLinks() */ @Override - public Builder link(Link link) { + public Builder link(Link link) { super.link(link); return this; } @@ -157,11 +157,11 @@ public class VAppNetworkConfiguration> ext * {@inheritDoc} */ @SuppressWarnings("unchecked") - public Builder fromResourceType(ResourceType in) { + public Builder fromResourceType(ResourceType in) { return Builder.class.cast(super.fromResourceType(in)); } - public Builder fromVAppNetworkConfiguration(VAppNetworkConfiguration in) { + public Builder fromVAppNetworkConfiguration(VAppNetworkConfiguration in) { return fromResourceType(in) .description(in.getDescription()) .configuration(in.getConfiguration()) @@ -238,7 +238,7 @@ public class VAppNetworkConfiguration> ext return true; if (o == null || getClass() != o.getClass()) return false; - VAppNetworkConfiguration that = VAppNetworkConfiguration.class.cast(o); + VAppNetworkConfiguration that = VAppNetworkConfiguration.class.cast(o); return equal(description, that.description) && equal(configuration, that.configuration) && equal(isDeployed, that.isDeployed) && diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationSettingData.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationSettingData.java index fd1e3576d5..3406562e5f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationSettingData.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/ResourceAllocationSettingData.java @@ -20,14 +20,12 @@ package org.jclouds.vcloud.director.v1_5.domain.cim; import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Collections; import java.util.List; import java.util.Map; import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; +import com.google.common.collect.*; /** * @@ -238,7 +236,7 @@ public class ResourceAllocationSettingData extends ManagedElement { * @see ResourceAllocationSettingData#getConnections */ public Builder connections(List connections) { - this.connections.addAll(checkNotNull(connections, "connections")); + this.connections = Lists.newArrayList(checkNotNull(connections, "connections")); return this; } @@ -246,7 +244,7 @@ public class ResourceAllocationSettingData extends ManagedElement { * @see ResourceAllocationSettingData#getHostResources */ public Builder hostResources(List hostResources) { - this.hostResources.addAll(checkNotNull(hostResources, "hostResources")); + this.hostResources = Lists.newArrayList(checkNotNull(hostResources, "hostResources")); return this; } @@ -665,7 +663,7 @@ public class ResourceAllocationSettingData extends ManagedElement { * network or switch port. */ public List getConnections() { - return connections; + return Collections.unmodifiableList(connections); } /** @@ -687,7 +685,7 @@ public class ResourceAllocationSettingData extends ManagedElement { * based on host resources that are identified by element values. */ public List getHostResources() { - return hostResources; + return Collections.unmodifiableList(hostResources); } @Override