VCloud Director 1.5: making sure collections in domain objects are immutable

This commit is contained in:
Adam Lowe 2012-03-05 21:31:51 +00:00
parent 969c5132eb
commit d1b0da081d
30 changed files with 218 additions and 234 deletions

View File

@ -23,11 +23,13 @@ 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.Collection;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -98,7 +100,7 @@ public class AvailableNetworks {
protected Set<Reference> networks = Sets.newLinkedHashSet(); protected Set<Reference> networks = Sets.newLinkedHashSet();
private AvailableNetworks(Set<Reference> networks) { private AvailableNetworks(Set<Reference> networks) {
this.networks = networks; this.networks = ImmutableSet.copyOf(networks);
} }
private AvailableNetworks() { private AvailableNetworks() {
@ -109,7 +111,7 @@ public class AvailableNetworks {
* Gets the value of the network property. * Gets the value of the network property.
*/ */
public Set<Reference> getNetworks() { public Set<Reference> getNetworks() {
return this.networks; return Collections.unmodifiableSet(this.networks);
} }
@Override @Override

View File

@ -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.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ -101,12 +102,10 @@ public class CaptureVAppParams
return this; return this;
} }
public CaptureVAppParams build() { public CaptureVAppParams build() {
return new CaptureVAppParams(description, name, source, sections); return new CaptureVAppParams(description, name, source, sections);
} }
@Override @Override
public Builder fromParamsType(ParamsType<CaptureVAppParams> in) { public Builder fromParamsType(ParamsType<CaptureVAppParams> in) {
return Builder.class.cast(super.fromParamsType(in)); return Builder.class.cast(super.fromParamsType(in));
@ -133,7 +132,6 @@ public class CaptureVAppParams
this.sections = ImmutableSet.copyOf(sections); this.sections = ImmutableSet.copyOf(sections);
} }
@XmlElement(name = "Source", required = true) @XmlElement(name = "Source", required = true)
protected Reference source; protected Reference source;
@XmlElementRef @XmlElementRef
@ -151,22 +149,9 @@ public class CaptureVAppParams
/** /**
* An ovf:Section to configure the captured vAppTemplate. * An ovf:Section to configure the captured vAppTemplate.
* Gets the value of the section property. *
* <p/> * Gets the value of the section property.
* <p/> *
* 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 <CODE>set</CODE> method for the section property.
* <p/>
* <p/>
* For example, to add a new item, do as follows:
* <pre>
* getSection().add(newItem);
* </pre>
* <p/>
* <p/>
* <p/>
* Objects of the following type(s) are allowed in the list * Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link Section> }{@code >} * {@link JAXBElement }{@code <}{@link Section> }{@code >}
* {@link JAXBElement }{@code <}{@link VirtualHardwareSection > }{@code >} * {@link JAXBElement }{@code <}{@link VirtualHardwareSection > }{@code >}
@ -188,7 +173,7 @@ public class CaptureVAppParams
* {@link JAXBElement }{@code <}{@link InstallSection> }{@code >} * {@link JAXBElement }{@code <}{@link InstallSection> }{@code >}
*/ */
public Set<? extends Section<?>> getSections() { public Set<? extends Section<?>> getSections() {
return this.sections; return Collections.unmodifiableSet(this.sections);
} }
@Override @Override

View File

@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
@ -173,7 +174,7 @@ public class CatalogItem extends EntityType<CatalogItem> {
private CatalogItem(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, String name, Reference entity, Set<Property> properties) { private CatalogItem(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, String name, Reference entity, Set<Property> properties) {
super(href, type, links, description, tasksInProgress, id, name); super(href, type, links, description, tasksInProgress, id, name);
this.entity = entity; this.entity = entity;
this.properties = properties; this.properties = ImmutableSet.copyOf(properties);
} }
private CatalogItem() { private CatalogItem() {

View File

@ -32,6 +32,7 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
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.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
@ -86,11 +87,11 @@ public class CatalogItems {
} }
private CatalogItems() { private CatalogItems() {
// For JAXB and builder use // For JAXB
} }
private CatalogItems(Set<Reference> catalogItems) { private CatalogItems(Set<Reference> catalogItems) {
this.catalogItems = catalogItems; this.catalogItems = ImmutableSet.copyOf(catalogItems);
} }
@XmlElement(name = "CatalogItem") @XmlElement(name = "CatalogItem")

View File

@ -22,6 +22,7 @@ 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.Collection;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -62,16 +63,8 @@ public class CatalogsList {
/** /**
* @see CatalogsList#getCatalogItems() * @see CatalogsList#getCatalogItems()
*/ */
public Builder catalogs(Collection<Reference> catalogReferences) { public Builder catalogs(Set<Reference> catalogReferences) {
this.catalogReferences = Sets.newLinkedHashSet(checkNotNull(catalogReferences, "catalogReferences")); this.catalogReferences = checkNotNull(catalogReferences, "catalogReferences");
return this;
}
/**
* @see CatalogsList#getCatalogItems()
*/
public Builder catalog(Reference catalog) {
this.catalogReferences.add(checkNotNull(catalog, "catalog"));
return this; return this;
} }
@ -99,7 +92,7 @@ public class CatalogsList {
* Gets the value of the catalogReferences property. * Gets the value of the catalogReferences property.
*/ */
public Set<Reference> getCatalogItems() { public Set<Reference> getCatalogItems() {
return this.catalogReferences; return Collections.unmodifiableSet(this.catalogReferences);
} }
@Override @Override

View File

@ -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.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set; 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;
@ -57,7 +58,7 @@ import com.google.common.collect.Sets;
* </pre> * </pre>
*/ */
@XmlType(name = "ComposeVAppParams", propOrder = { @XmlType(name = "ComposeVAppParams", propOrder = {
"sourcedItem", "sourcedItems",
"allEULAsAccepted" "allEULAsAccepted"
}) })
@XmlSeeAlso({ @XmlSeeAlso({
@ -78,15 +79,15 @@ public class ComposeVAppParams
public static class Builder extends VAppCreationParamsType.Builder<ComposeVAppParams> { public static class Builder extends VAppCreationParamsType.Builder<ComposeVAppParams> {
private Set<SourcedCompositionItemParam> sourcedItem = Sets.newLinkedHashSet(); private Set<SourcedCompositionItemParam> sourcedItems = Sets.newLinkedHashSet();
private Boolean allEULAsAccepted; private Boolean allEULAsAccepted;
private Boolean linkedClone; private Boolean linkedClone;
/** /**
* @see ComposeVAppParams#getSourcedItem() * @see ComposeVAppParams#getSourcedItems()
*/ */
public Builder sourcedItem(Set<SourcedCompositionItemParam> sourcedItem) { public Builder sourcedItems(Set<SourcedCompositionItemParam> sourcedItems) {
this.sourcedItem = checkNotNull(sourcedItem, "sourcedItem"); this.sourcedItems = checkNotNull(sourcedItems, "sourcedItems");
return this; return this;
} }
@ -109,7 +110,7 @@ public class ComposeVAppParams
public ComposeVAppParams build() { public ComposeVAppParams build() {
return new ComposeVAppParams(description, name, vAppParent, instantiationParams, deploy, powerOn, 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) { public Builder fromComposeVAppParams(ComposeVAppParams in) {
return fromVAppCreationParamsType(in) return fromVAppCreationParamsType(in)
.sourcedItem(in.getSourcedItem()) .sourcedItems(in.getSourcedItems())
.allEULAsAccepted(in.isAllEULAsAccepted()) .allEULAsAccepted(in.isAllEULAsAccepted())
.linkedClone(in.isLinkedClone()); .linkedClone(in.isLinkedClone());
} }
} }
public ComposeVAppParams(String description, String name, Reference vAppParent, InstantiationParams instantiationParams, public ComposeVAppParams(String description, String name, Reference vAppParent, InstantiationParams instantiationParams,
Boolean deploy, Boolean powerOn, Set<SourcedCompositionItemParam> sourcedItem, Boolean allEULAsAccepted, Boolean linkedClone) { Boolean deploy, Boolean powerOn, Set<SourcedCompositionItemParam> sourcedItems, Boolean allEULAsAccepted, Boolean linkedClone) {
super(description, name, vAppParent, instantiationParams, deploy, powerOn); super(description, name, vAppParent, instantiationParams, deploy, powerOn);
this.sourcedItem = ImmutableSet.copyOf(sourcedItem); this.sourcedItems = ImmutableSet.copyOf(sourcedItems);
this.allEULAsAccepted = allEULAsAccepted; this.allEULAsAccepted = allEULAsAccepted;
this.linkedClone = linkedClone; this.linkedClone = linkedClone;
} }
@ -140,7 +141,7 @@ public class ComposeVAppParams
@XmlElement(name = "SourcedItem") @XmlElement(name = "SourcedItem")
protected Set<SourcedCompositionItemParam> sourcedItem = Sets.newLinkedHashSet(); protected Set<SourcedCompositionItemParam> sourcedItems = Sets.newLinkedHashSet();
@XmlElement(name = "AllEULAsAccepted") @XmlElement(name = "AllEULAsAccepted")
protected Boolean allEULAsAccepted; protected Boolean allEULAsAccepted;
@XmlAttribute @XmlAttribute
@ -148,26 +149,9 @@ public class ComposeVAppParams
/** /**
* Gets the value of the sourcedItem property. * Gets the value of the sourcedItem property.
* <p/>
* <p/>
* 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 <CODE>set</CODE> method for the sourcedItem property.
* <p/>
* <p/>
* For example, to add a new item, do as follows:
* <pre>
* getSourcedItem().add(newItem);
* </pre>
* <p/>
* <p/>
* <p/>
* Objects of the following type(s) are allowed in the list
* {@link SourcedCompositionItemParam }
*/ */
public Set<SourcedCompositionItemParam> getSourcedItem() { public Set<SourcedCompositionItemParam> getSourcedItems() {
return this.sourcedItem; return Collections.unmodifiableSet(this.sourcedItems);
} }
/** /**
@ -201,14 +185,14 @@ public class ComposeVAppParams
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
ComposeVAppParams that = ComposeVAppParams.class.cast(o); ComposeVAppParams that = ComposeVAppParams.class.cast(o);
return equal(sourcedItem, that.sourcedItem) && return equal(sourcedItems, that.sourcedItems) &&
equal(allEULAsAccepted, that.allEULAsAccepted) && equal(allEULAsAccepted, that.allEULAsAccepted) &&
equal(linkedClone, that.linkedClone); equal(linkedClone, that.linkedClone);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(sourcedItem, return Objects.hashCode(sourcedItems,
allEULAsAccepted, allEULAsAccepted,
linkedClone); linkedClone);
} }
@ -216,7 +200,7 @@ public class ComposeVAppParams
@Override @Override
public String toString() { public String toString() {
return Objects.toStringHelper("") return Objects.toStringHelper("")
.add("sourcedItem", sourcedItem) .add("sourcedItem", sourcedItems)
.add("allEULAsAccepted", allEULAsAccepted) .add("allEULAsAccepted", allEULAsAccepted)
.add("linkedClone", linkedClone).toString(); .add("linkedClone", linkedClone).toString();
} }

View File

@ -23,6 +23,7 @@ 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.net.URI; import java.net.URI;
import java.util.Collections;
import java.util.Set; 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;
@ -187,7 +188,7 @@ public class CustomizationSection extends SectionType<CustomizationSection> {
* Gets the value of the links property. * Gets the value of the links property.
*/ */
public Set<Link> getLinks() { public Set<Link> getLinks() {
return this.links; return Collections.unmodifiableSet(this.links);
} }
/** /**

View File

@ -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.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ -112,7 +113,7 @@ public class FilesList {
* Gets the value of the file property. * Gets the value of the file property.
*/ */
public List<File> getFiles() { public List<File> getFiles() {
return this.files; return Collections.unmodifiableList(this.files);
} }
@Override @Override

View File

@ -237,7 +237,7 @@ public class GuestCustomizationSection extends SectionType<GuestCustomizationSec
} }
/** /**
* @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getLink() * @see org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection#getLinks()
*/ */
public Builder links(Set<Link> links) { public Builder links(Set<Link> links) {
this.links = checkNotNull(links, "links"); this.links = checkNotNull(links, "links");
@ -285,7 +285,7 @@ public class GuestCustomizationSection extends SectionType<GuestCustomizationSec
.resetPasswordRequired(in.isResetPasswordRequired()) .resetPasswordRequired(in.isResetPasswordRequired())
.customizationScript(in.getCustomizationScript()) .customizationScript(in.getCustomizationScript())
.computerName(in.getComputerName()) .computerName(in.getComputerName())
.links(in.getLink()) .links(in.getLinks())
.href(in.getHref()) .href(in.getHref())
.type(in.getType()); .type(in.getType());
} }
@ -528,7 +528,7 @@ public class GuestCustomizationSection extends SectionType<GuestCustomizationSec
* Objects of the following type(s) are allowed in the list * Objects of the following type(s) are allowed in the list
* {@link Link } * {@link Link }
*/ */
public Set<Link> getLink() { public Set<Link> getLinks() {
return Collections.unmodifiableSet(this.links); return Collections.unmodifiableSet(this.links);
} }

View File

@ -23,6 +23,7 @@ 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.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.xml.bind.JAXBElement; 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<? extends SectionType<?>> sections = Sets.newLinkedHashSet(); protected Set<? extends SectionType<?>> sections = Sets.newLinkedHashSet();
/** /**
@ -113,20 +114,6 @@ public class InstantiationParams {
* <p/> * <p/>
* Gets the value of the section property. * Gets the value of the section property.
* <p/> * <p/>
* <p/>
* 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 <CODE>set</CODE> method for the section property.
* <p/>
* <p/>
* For example, to add a new item, do as follows:
* <pre>
* getSection().add(newItem);
* </pre>
* <p/>
* <p/>
* <p/>
* Objects of the following type(s) are allowed in the list * Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link SectionType }{@code >} * {@link JAXBElement }{@code <}{@link SectionType }{@code >}
* {@link JAXBElement }{@code <}{@link VirtualHardwareSection }{@code >} * {@link JAXBElement }{@code <}{@link VirtualHardwareSection }{@code >}
@ -148,7 +135,7 @@ public class InstantiationParams {
* {@link JAXBElement }{@code <}{@link InstallSection }{@code >} * {@link JAXBElement }{@code <}{@link InstallSection }{@code >}
*/ */
public Set<? extends SectionType<?>> getSections() { public Set<? extends SectionType<?>> getSections() {
return this.sections; return Collections.unmodifiableSet(this.sections);
} }
@Override @Override

View File

@ -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.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -52,7 +53,7 @@ public class IpAddresses {
* @see IpAddresses#getIpAddresses() * @see IpAddresses#getIpAddresses()
*/ */
public Builder ipAddresses(Set<String> ipAddresses) { public Builder ipAddresses(Set<String> ipAddresses) {
this.ipAddresses = Sets.newLinkedHashSet(checkNotNull(ipAddresses, "ipAddresses")); this.ipAddresses.addAll(checkNotNull(ipAddresses, "ipAddresses"));
return this; return this;
} }
@ -85,7 +86,7 @@ public class IpAddresses {
private Set<String> ipAddresses = Sets.newLinkedHashSet(); private Set<String> ipAddresses = Sets.newLinkedHashSet();
public Set<String> getIpAddresses() { public Set<String> getIpAddresses() {
return ImmutableSet.copyOf(ipAddresses); return Collections.unmodifiableSet(ipAddresses);
} }
@Override @Override

View File

@ -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.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.LinkedHashSet;
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.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -85,7 +87,7 @@ public class IpRanges {
private Set<IpRange> ipRanges = Sets.newLinkedHashSet(); private Set<IpRange> ipRanges = Sets.newLinkedHashSet();
public Set<IpRange> getIpRanges() { public Set<IpRange> getIpRanges() {
return ImmutableSet.copyOf(ipRanges); return Collections.unmodifiableSet(ipRanges);
} }
@Override @Override

View File

@ -24,18 +24,20 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.Set; 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.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType; import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -88,8 +90,8 @@ public class LeaseSettingsSection extends SectionType<LeaseSettingsSection> {
private Set<Link> links = Sets.newLinkedHashSet(); private Set<Link> links = Sets.newLinkedHashSet();
private Integer deploymentLeaseInSeconds; private Integer deploymentLeaseInSeconds;
private Integer storageLeaseInSeconds; private Integer storageLeaseInSeconds;
private XMLGregorianCalendar deploymentLeaseExpiration; private Date deploymentLeaseExpiration;
private XMLGregorianCalendar storageLeaseExpiration; private Date storageLeaseExpiration;
private URI href; private URI href;
private String type; private String type;
@ -120,7 +122,7 @@ public class LeaseSettingsSection extends SectionType<LeaseSettingsSection> {
/** /**
* @see LeaseSettingsSection#getDeploymentLeaseExpiration() * @see LeaseSettingsSection#getDeploymentLeaseExpiration()
*/ */
public Builder deploymentLeaseExpiration(XMLGregorianCalendar deploymentLeaseExpiration) { public Builder deploymentLeaseExpiration(Date deploymentLeaseExpiration) {
this.deploymentLeaseExpiration = deploymentLeaseExpiration; this.deploymentLeaseExpiration = deploymentLeaseExpiration;
return this; return this;
} }
@ -128,7 +130,7 @@ public class LeaseSettingsSection extends SectionType<LeaseSettingsSection> {
/** /**
* @see LeaseSettingsSection#getStorageLeaseExpiration() * @see LeaseSettingsSection#getStorageLeaseExpiration()
*/ */
public Builder storageLeaseExpiration(XMLGregorianCalendar storageLeaseExpiration) { public Builder storageLeaseExpiration(Date storageLeaseExpiration) {
this.storageLeaseExpiration = storageLeaseExpiration; this.storageLeaseExpiration = storageLeaseExpiration;
return this; return this;
} }
@ -200,10 +202,10 @@ public class LeaseSettingsSection extends SectionType<LeaseSettingsSection> {
protected Integer storageLeaseInSeconds; protected Integer storageLeaseInSeconds;
@XmlElement(name = "DeploymentLeaseExpiration") @XmlElement(name = "DeploymentLeaseExpiration")
@XmlSchemaType(name = "dateTime") @XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar deploymentLeaseExpiration; protected Date deploymentLeaseExpiration;
@XmlElement(name = "StorageLeaseExpiration") @XmlElement(name = "StorageLeaseExpiration")
@XmlSchemaType(name = "dateTime") @XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar storageLeaseExpiration; protected Date storageLeaseExpiration;
@XmlAttribute @XmlAttribute
@XmlSchemaType(name = "anyURI") @XmlSchemaType(name = "anyURI")
protected URI href; protected URI href;
@ -211,10 +213,10 @@ public class LeaseSettingsSection extends SectionType<LeaseSettingsSection> {
protected String type; protected String type;
private LeaseSettingsSection(@Nullable String info, @Nullable Boolean required, Set<Link> links, Integer deploymentLeaseInSeconds, private LeaseSettingsSection(@Nullable String info, @Nullable Boolean required, Set<Link> links, Integer deploymentLeaseInSeconds,
Integer storageLeaseInSeconds, XMLGregorianCalendar deploymentLeaseExpiration, Integer storageLeaseInSeconds, Date deploymentLeaseExpiration,
XMLGregorianCalendar storageLeaseExpiration, URI href, String type) { Date storageLeaseExpiration, URI href, String type) {
super(info, required); super(info, required);
this.links = links; this.links = ImmutableSet.copyOf(links);
this.deploymentLeaseInSeconds = deploymentLeaseInSeconds; this.deploymentLeaseInSeconds = deploymentLeaseInSeconds;
this.storageLeaseInSeconds = storageLeaseInSeconds; this.storageLeaseInSeconds = storageLeaseInSeconds;
this.deploymentLeaseExpiration = deploymentLeaseExpiration; this.deploymentLeaseExpiration = deploymentLeaseExpiration;
@ -229,23 +231,6 @@ public class LeaseSettingsSection extends SectionType<LeaseSettingsSection> {
/** /**
* Gets the value of the link property. * Gets the value of the link property.
* <p/>
* <p/>
* 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 <CODE>set</CODE> method for the link property.
* <p/>
* <p/>
* For example, to add a new item, do as follows:
* <pre>
* getLink().add(newItem);
* </pre>
* <p/>
* <p/>
* <p/>
* Objects of the following type(s) are allowed in the list
* {@link Link }
*/ */
public Set<Link> getLinks() { public Set<Link> getLinks() {
return Collections.unmodifiableSet(this.links); return Collections.unmodifiableSet(this.links);
@ -273,21 +258,15 @@ public class LeaseSettingsSection extends SectionType<LeaseSettingsSection> {
/** /**
* Gets the value of the deploymentLeaseExpiration property. * Gets the value of the deploymentLeaseExpiration property.
*
* @return possible object is
* {@link XMLGregorianCalendar }
*/ */
public XMLGregorianCalendar getDeploymentLeaseExpiration() { public Date getDeploymentLeaseExpiration() {
return deploymentLeaseExpiration; return deploymentLeaseExpiration;
} }
/** /**
* Gets the value of the storageLeaseExpiration property. * Gets the value of the storageLeaseExpiration property.
*
* @return possible object is
* {@link XMLGregorianCalendar }
*/ */
public XMLGregorianCalendar getStorageLeaseExpiration() { public Date getStorageLeaseExpiration() {
return storageLeaseExpiration; return storageLeaseExpiration;
} }

View File

@ -22,6 +22,7 @@ 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.net.URI; import java.net.URI;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -105,8 +106,7 @@ public class Metadata extends ResourceType<Metadata> {
*/ */
@Override @Override
public Builder links(Set<Link> links) { public Builder links(Set<Link> links) {
super.links(Sets.newLinkedHashSet(checkNotNull(links, "links"))); return Builder.class.cast(super.links(links));
return this;
} }
/** /**
@ -145,7 +145,7 @@ public class Metadata extends ResourceType<Metadata> {
private Set<MetadataEntry> metadataEntries = Sets.newLinkedHashSet(); private Set<MetadataEntry> metadataEntries = Sets.newLinkedHashSet();
public Set<MetadataEntry> getMetadataEntries() { public Set<MetadataEntry> getMetadataEntries() {
return ImmutableSet.copyOf(metadataEntries); return Collections.unmodifiableSet(metadataEntries);
} }
@Override @Override

View File

@ -81,7 +81,7 @@ public class NetworkConfigSection extends SectionType<NetworkConfigSection> {
public static class Builder extends SectionType.Builder<NetworkConfigSection> { public static class Builder extends SectionType.Builder<NetworkConfigSection> {
private Set<Link> links = Sets.newLinkedHashSet(); private Set<Link> links = Sets.newLinkedHashSet();
private Set<VAppNetworkConfiguration<?>> networkConfigs = Sets.newLinkedHashSet(); private Set<VAppNetworkConfiguration> networkConfigs = Sets.newLinkedHashSet();
private URI href; private URI href;
private String type; private String type;
@ -96,7 +96,7 @@ public class NetworkConfigSection extends SectionType<NetworkConfigSection> {
/** /**
* @see NetworkConfigSection#getNetworkConfigs() * @see NetworkConfigSection#getNetworkConfigs()
*/ */
public Builder networkConfig(Set<VAppNetworkConfiguration<?>> networkConfigs) { public Builder networkConfigs(Set<VAppNetworkConfiguration> networkConfigs) {
this.networkConfigs = checkNotNull(networkConfigs, "networkConfigs"); this.networkConfigs = checkNotNull(networkConfigs, "networkConfigs");
return this; return this;
} }
@ -125,7 +125,7 @@ public class NetworkConfigSection extends SectionType<NetworkConfigSection> {
public Builder fromNetworkConfigSection(NetworkConfigSection in) { public Builder fromNetworkConfigSection(NetworkConfigSection in) {
return fromSection(in) return fromSection(in)
.links(in.getLinks()) .links(in.getLinks())
.networkConfig(in.getNetworkConfigs()) .networkConfigs(in.getNetworkConfigs())
.href(in.getHref()) .href(in.getHref())
.type(in.getType()); .type(in.getType());
} }
@ -157,16 +157,16 @@ public class NetworkConfigSection extends SectionType<NetworkConfigSection> {
} }
@XmlElement(name = "Link") @XmlElement(name = "Link")
protected Set<Link> links; protected Set<Link> links = Sets.newLinkedHashSet();
@XmlElement(name = "NetworkConfig") @XmlElement(name = "NetworkConfig")
protected Set<VAppNetworkConfiguration<?>> networkConfigs; protected Set<VAppNetworkConfiguration> networkConfigs = Sets.newLinkedHashSet();
@XmlAttribute @XmlAttribute
@XmlSchemaType(name = "anyURI") @XmlSchemaType(name = "anyURI")
protected URI href; protected URI href;
@XmlAttribute @XmlAttribute
protected String type; protected String type;
public NetworkConfigSection(@Nullable String info, @Nullable Boolean required, Set<Link> links, Set<VAppNetworkConfiguration<?>> networkConfigs, public NetworkConfigSection(@Nullable String info, @Nullable Boolean required, Set<Link> links, Set<VAppNetworkConfiguration> networkConfigs,
URI href, String type) { URI href, String type) {
super(info, required); super(info, required);
this.links = ImmutableSet.copyOf(links); this.links = ImmutableSet.copyOf(links);
@ -189,7 +189,7 @@ public class NetworkConfigSection extends SectionType<NetworkConfigSection> {
/** /**
* Gets the value of the networkConfig property. * Gets the value of the networkConfig property.
*/ */
public Set<VAppNetworkConfiguration<?>> getNetworkConfigs() { public Set<VAppNetworkConfiguration> getNetworkConfigs() {
return Collections.unmodifiableSet(this.networkConfigs); return Collections.unmodifiableSet(this.networkConfigs);
} }

View File

@ -44,9 +44,9 @@ public class NetworkConfiguration {
public static class Builder { public static class Builder {
private IpScope ipScope; private IpScope ipScope;
private ReferenceType<?> parentNetwork; private Reference parentNetwork;
private String fenceMode; private String fenceMode;
private boolean retainNetInfoAcrossDeployments; private Boolean retainNetInfoAcrossDeployments;
private NetworkFeatures features; private NetworkFeatures features;
private SyslogServerSettings syslogServerSettings; private SyslogServerSettings syslogServerSettings;
private RouterInfo routerInfo; private RouterInfo routerInfo;
@ -62,7 +62,7 @@ public class NetworkConfiguration {
/** /**
* @see NetworkConfiguration#getParentNetwork() * @see NetworkConfiguration#getParentNetwork()
*/ */
public Builder parentNetwork(ReferenceType<?> parentNetwork) { public Builder parentNetwork(Reference parentNetwork) {
this.parentNetwork = parentNetwork; this.parentNetwork = parentNetwork;
return this; 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) { NetworkFeatures features, SyslogServerSettings syslogServerSettings, RouterInfo routerInfo) {
this.ipScope = ipScope; this.ipScope = ipScope;
this.parentNetwork = parentNetwork; this.parentNetwork = parentNetwork;
@ -138,11 +138,11 @@ public class NetworkConfiguration {
@XmlElement(name = "IpScope") @XmlElement(name = "IpScope")
private IpScope ipScope; private IpScope ipScope;
@XmlElement(name = "ParentNetwork") @XmlElement(name = "ParentNetwork")
private ReferenceType<?> parentNetwork; private Reference parentNetwork;
@XmlElement(name = "FenceMode") @XmlElement(name = "FenceMode")
private String fenceMode; private String fenceMode;
@XmlElement(name = "RetainNetInfoAcrossDeployments") @XmlElement(name = "RetainNetInfoAcrossDeployments")
private boolean retainNetInfoAcrossDeployments = false; private Boolean retainNetInfoAcrossDeployments;
@XmlElement(name = "Features") @XmlElement(name = "Features")
private NetworkFeatures features; private NetworkFeatures features;
@XmlElement(name = "SyslogServerSettings") @XmlElement(name = "SyslogServerSettings")
@ -162,7 +162,7 @@ public class NetworkConfiguration {
/** /**
* @return reference to parent network. * @return reference to parent network.
*/ */
public ReferenceType<?> getParentNetwork() { public Reference getParentNetwork() {
return parentNetwork; return parentNetwork;
} }
@ -212,7 +212,8 @@ public class NetworkConfiguration {
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
NetworkConfiguration that = NetworkConfiguration.class.cast(o); 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(fenceMode, that.fenceMode) &&
equal(retainNetInfoAcrossDeployments, that.retainNetInfoAcrossDeployments) && equal(retainNetInfoAcrossDeployments, that.retainNetInfoAcrossDeployments) &&
equal(features, that.features) && equal(features, that.features) &&

View File

@ -23,6 +23,7 @@ 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.net.URI; import java.net.URI;
import java.util.Collections;
import java.util.Set; 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;
@ -83,7 +84,7 @@ public class NetworkConnectionSection extends SectionType<NetworkConnectionSecti
public static class Builder extends SectionType.Builder<NetworkConnectionSection> { public static class Builder extends SectionType.Builder<NetworkConnectionSection> {
private Integer primaryNetworkConnectionIndex; private Integer primaryNetworkConnectionIndex;
private Set<NetworkConnection> networkConnection = Sets.newLinkedHashSet(); private Set<NetworkConnection> networkConnections = Sets.newLinkedHashSet();
private Set<Link> links = Sets.newLinkedHashSet(); private Set<Link> links = Sets.newLinkedHashSet();
private URI href; private URI href;
private String type; private String type;
@ -99,8 +100,8 @@ public class NetworkConnectionSection extends SectionType<NetworkConnectionSecti
/** /**
* @see NetworkConnectionSection#getNetworkConnections() * @see NetworkConnectionSection#getNetworkConnections()
*/ */
public Builder networkConnection(Set<NetworkConnection> networkConnection) { public Builder networkConnections(Set<NetworkConnection> networkConnections) {
this.networkConnection = checkNotNull(networkConnection, "networkConnection"); this.networkConnections = checkNotNull(networkConnections, "networkConnection");
return this; return this;
} }
@ -130,14 +131,14 @@ public class NetworkConnectionSection extends SectionType<NetworkConnectionSecti
public NetworkConnectionSection build() { public NetworkConnectionSection build() {
return new NetworkConnectionSection(info, required, primaryNetworkConnectionIndex, networkConnection, links, href, type); return new NetworkConnectionSection(info, required, primaryNetworkConnectionIndex, networkConnections, links, href, type);
} }
public Builder fromNetworkConnectionSection(NetworkConnectionSection in) { public Builder fromNetworkConnectionSection(NetworkConnectionSection in) {
return fromSection(in) return fromSection(in)
.primaryNetworkConnectionIndex(in.getPrimaryNetworkConnectionIndex()) .primaryNetworkConnectionIndex(in.getPrimaryNetworkConnectionIndex())
.networkConnection(in.getNetworkConnections()) .networkConnections(in.getNetworkConnections())
.links(in.getLinks()) .links(in.getLinks())
.href(in.getHref()) .href(in.getHref())
.type(in.getType()); .type(in.getType());
@ -212,7 +213,7 @@ public class NetworkConnectionSection extends SectionType<NetworkConnectionSecti
* {@link NetworkConnection } * {@link NetworkConnection }
*/ */
public Set<NetworkConnection> getNetworkConnections() { public Set<NetworkConnection> getNetworkConnections() {
return this.networkConnections; return Collections.unmodifiableSet(this.networkConnections);
} }
/** /**
@ -222,7 +223,7 @@ public class NetworkConnectionSection extends SectionType<NetworkConnectionSecti
* {@link Link } * {@link Link }
*/ */
public Set<Link> getLinks() { public Set<Link> getLinks() {
return this.links; return Collections.unmodifiableSet(this.links);
} }
/** /**

View File

@ -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.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set; 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.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -47,12 +49,12 @@ public class NetworkFeatures {
public static class Builder { public static class Builder {
private Set<NetworkService> services = Sets.newLinkedHashSet(); private Set<NetworkServiceType> services = Sets.newLinkedHashSet();
/** /**
* @see NetworkFeatures#getNetworkServices() * @see NetworkFeatures#getNetworkServices()
*/ */
public Builder services(Set<NetworkService> services) { public Builder services(Set<NetworkServiceType> services) {
this.services = Sets.newLinkedHashSet(checkNotNull(services, "services")); this.services = Sets.newLinkedHashSet(checkNotNull(services, "services"));
return this; return this;
} }
@ -60,7 +62,7 @@ public class NetworkFeatures {
/** /**
* @see NetworkFeatures#getNetworkServices() * @see NetworkFeatures#getNetworkServices()
*/ */
public Builder service(NetworkService service) { public Builder service(NetworkServiceType service) {
services.add(checkNotNull(service, "service")); services.add(checkNotNull(service, "service"));
return this; return this;
} }
@ -78,19 +80,19 @@ public class NetworkFeatures {
// For JAXB and builder use // For JAXB and builder use
} }
public NetworkFeatures(Set<NetworkService> services) { public NetworkFeatures(Set<NetworkServiceType> services) {
this.services = services; this.services = ImmutableSet.copyOf(services);
} }
@XmlElement(name = "NetworkService") @XmlElementRef
private Set<NetworkService> services = Sets.newLinkedHashSet(); private Set<NetworkServiceType> services = Sets.newLinkedHashSet();
/** /**
* @return a Network service. May be any of DhcpService, NatService, IpsecVpnService, * @return a Network service. May be any of DhcpService, NatService, IpsecVpnService,
* DhcpService, or StaticRoutingService. * DhcpService, or StaticRoutingService.
*/ */
public Set<NetworkService> getNetworkServices() { public Set<NetworkServiceType> getNetworkServices() {
return ImmutableSet.copyOf(services); return Collections.unmodifiableSet(services);
} }
@Override @Override

View File

@ -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.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -90,7 +91,7 @@ public class OrgList {
private Set<Reference> orgs = Sets.newLinkedHashSet(); private Set<Reference> orgs = Sets.newLinkedHashSet();
public Set<Reference> getOrgs() { public Set<Reference> getOrgs() {
return ImmutableSet.copyOf(orgs); return Collections.unmodifiableSet(orgs);
} }
@Override @Override

View File

@ -23,6 +23,7 @@ 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.net.URI; import java.net.URI;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
@ -55,7 +56,7 @@ import com.google.common.collect.Sets;
* </pre> * </pre>
*/ */
@XmlType(name = "ProductSectionList", propOrder = { @XmlType(name = "ProductSectionList", propOrder = {
"productSection" "productSections"
}) })
public class ProductSectionList public class ProductSectionList
extends ResourceType<ProductSectionList> extends ResourceType<ProductSectionList>
@ -76,9 +77,9 @@ public class ProductSectionList
private Set<ProductSection> productSections = Sets.newLinkedHashSet(); private Set<ProductSection> productSections = Sets.newLinkedHashSet();
/** /**
* @see ProductSectionList#getProductSection() * @see ProductSectionList#getProductSections()
*/ */
public Builder productSection(Set<ProductSection> productSections) { public Builder productSections(Set<ProductSection> productSections) {
this.productSections = checkNotNull(productSections, "productSection"); this.productSections = checkNotNull(productSections, "productSection");
return this; return this;
} }
@ -89,7 +90,6 @@ public class ProductSectionList
return productSectionList; return productSectionList;
} }
/** /**
* @see ResourceType#getHref() * @see ResourceType#getHref()
*/ */
@ -134,7 +134,7 @@ public class ProductSectionList
public Builder fromProductSectionList(ProductSectionList in) { public Builder fromProductSectionList(ProductSectionList in) {
return fromResourceType(in) return fromResourceType(in)
.productSection(in.getProductSection()); .productSections(in.getProductSections());
} }
} }
@ -142,19 +142,19 @@ public class ProductSectionList
// For JAXB and builder use // For JAXB and builder use
} }
private ProductSectionList(Set<ProductSection> productSection) { private ProductSectionList(Set<ProductSection> productSections) {
this.productSection = ImmutableSet.copyOf(productSection); this.productSections = ImmutableSet.copyOf(productSections);
} }
@XmlElement(name = "ProductSection", namespace = "http://schemas.dmtf.org/ovf/envelope/1") @XmlElement(name = "ProductSection", namespace = "http://schemas.dmtf.org/ovf/envelope/1")
protected Set<ProductSection> productSection = Sets.newLinkedHashSet(); protected Set<ProductSection> productSections = Sets.newLinkedHashSet();
/** /**
* Gets the value of the productSection property. * Gets the value of the productSection property.
*/ */
public Set<ProductSection> getProductSection() { public Set<ProductSection> getProductSections() {
return this.productSection; return Collections.unmodifiableSet(this.productSections);
} }
@Override @Override
@ -164,18 +164,18 @@ public class ProductSectionList
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
ProductSectionList that = ProductSectionList.class.cast(o); ProductSectionList that = ProductSectionList.class.cast(o);
return equal(productSection, that.productSection); return equal(productSections, that.productSections);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(productSection); return Objects.hashCode(productSections);
} }
@Override @Override
public String toString() { public String toString() {
return Objects.toStringHelper("") return Objects.toStringHelper("")
.add("productSection", productSection).toString(); .add("productSections", productSections).toString();
} }
} }

View File

@ -19,9 +19,15 @@
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.Preconditions.checkNotNull;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
/** /**
* Parameters to be used for vm relocation. * Parameters to be used for vm relocation.
@ -43,13 +49,38 @@ import javax.xml.bind.annotation.XmlType;
* &lt;/complexType> * &lt;/complexType>
* </pre> * </pre>
*/ */
@XmlType(name = "RelocateParams", propOrder = { @XmlRootElement(name = "RelocateParams")
@XmlType(propOrder = {
"datastore" "datastore"
}) })
public class RelocateParams { 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) @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. * Gets the value of the datastore property.
@ -60,4 +91,25 @@ public class RelocateParams {
public ReferenceType<?> getDatastore() { public ReferenceType<?> getDatastore() {
return datastore; 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();
}
} }

View File

@ -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.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
@ -72,7 +73,7 @@ public class ResourceEntities {
* @see ResourceEntities#getResourceEntities() * @see ResourceEntities#getResourceEntities()
*/ */
public Builder resourceEntities(Set<Reference> resourceEntities) { public Builder resourceEntities(Set<Reference> resourceEntities) {
this.resourceEntities = checkNotNull(resourceEntities, "resourceEntities"); this.resourceEntities = Sets.newLinkedHashSet(checkNotNull(resourceEntities, "resourceEntities"));
return this; return this;
} }
@ -110,7 +111,7 @@ public class ResourceEntities {
* Gets the value of the resourceEntity property. * Gets the value of the resourceEntity property.
*/ */
public Set<Reference> getResourceEntities() { public Set<Reference> getResourceEntities() {
return this.resourceEntities; return Collections.unmodifiableSet(this.resourceEntities);
} }
@Override @Override

View File

@ -22,12 +22,14 @@ 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.net.URI; import java.net.URI;
import java.util.Collections;
import java.util.Set; 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 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.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
@ -100,7 +102,7 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
protected ResourceType(URI href, String type, Set<Link> links) { protected ResourceType(URI href, String type, Set<Link> links) {
this.href = href; this.href = href;
this.type = type; this.type = type;
this.links = links; this.links = ImmutableSet.copyOf(links);
} }
protected ResourceType() { protected ResourceType() {
@ -148,7 +150,7 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
* Set of optional links to an entity or operation associated with this object. * Set of optional links to an entity or operation associated with this object.
*/ */
public Set<Link> getLinks() { public Set<Link> getLinks() {
return links; return Collections.unmodifiableSet(links);
} }
@Override @Override

View File

@ -22,6 +22,7 @@ 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.net.URI; import java.net.URI;
import java.util.Collections;
import java.util.Set; 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;
@ -129,7 +130,7 @@ public class Session {
private URI href; private URI href;
public Set<Link> getLinks() { public Set<Link> getLinks() {
return ImmutableSet.copyOf(links); return Collections.unmodifiableSet(links);
} }
/** /**

View File

@ -20,7 +20,9 @@
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;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set; 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;
@ -107,7 +109,7 @@ public class SourcedCompositionItemParam {
* @see SourcedCompositionItemParam#getNetworkAssignments() * @see SourcedCompositionItemParam#getNetworkAssignments()
*/ */
public Builder networkAssignments(Set<NetworkAssignment> networkAssignments) { public Builder networkAssignments(Set<NetworkAssignment> networkAssignments) {
this.networkAssignments = networkAssignments; this.networkAssignments = checkNotNull(networkAssignments, "networkAssignments");
return this; return this;
} }
@ -189,26 +191,9 @@ public class SourcedCompositionItemParam {
/** /**
* Gets the value of the networkAssignment property. * Gets the value of the networkAssignment property.
* <p/>
* <p/>
* 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 <CODE>set</CODE> method for the networkAssignment property.
* <p/>
* <p/>
* For example, to add a new item, do as follows:
* <pre>
* getNetworkAssignment().add(newItem);
* </pre>
* <p/>
* <p/>
* <p/>
* Objects of the following type(s) are allowed in the list
* {@link NetworkAssignment }
*/ */
public Set<NetworkAssignment> getNetworkAssignments() { public Set<NetworkAssignment> getNetworkAssignments() {
return this.networkAssignments; return Collections.unmodifiableSet(this.networkAssignments);
} }
/** /**

View File

@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -100,7 +101,7 @@ public class SupportedHardwareVersions {
} }
private SupportedHardwareVersions(Set<String> supportedHardwareVersions) { private SupportedHardwareVersions(Set<String> supportedHardwareVersions) {
this.supportedHardwareVersions = supportedHardwareVersions; this.supportedHardwareVersions = ImmutableSet.copyOf(supportedHardwareVersions);
} }

View File

@ -22,6 +22,7 @@ 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.Collection;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -52,7 +53,7 @@ public class TasksInProgress {
* @see TasksInProgress#getTasks() * @see TasksInProgress#getTasks()
*/ */
public Builder tasks(Set<Task> tasks) { public Builder tasks(Set<Task> tasks) {
this.tasks = Sets.newLinkedHashSet(checkNotNull(tasks, "tasks")); this.tasks = checkNotNull(tasks, "tasks");
return this; return this;
} }
@ -73,11 +74,11 @@ public class TasksInProgress {
} }
} }
protected TasksInProgress() { private TasksInProgress() {
// For JAXB and builder use // For JAXB and builder use
} }
protected TasksInProgress(Collection<Task> tasks) { private TasksInProgress(Collection<Task> tasks) {
this.tasks = ImmutableSet.copyOf(tasks); this.tasks = ImmutableSet.copyOf(tasks);
} }
@ -85,7 +86,7 @@ public class TasksInProgress {
private Set<Task> tasks = Sets.newLinkedHashSet(); private Set<Task> tasks = Sets.newLinkedHashSet();
public Set<Task> getTasks() { public Set<Task> getTasks() {
return ImmutableSet.copyOf(tasks); return Collections.unmodifiableSet(tasks);
} }
@Override @Override

View File

@ -22,6 +22,7 @@ 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.net.URI; import java.net.URI;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@ -172,7 +173,7 @@ public class TasksList extends EntityType<TasksList> {
private Set<Task> tasks = Sets.newLinkedHashSet(); private Set<Task> tasks = Sets.newLinkedHashSet();
public Set<Task> getTasks() { public Set<Task> getTasks() {
return ImmutableSet.copyOf(tasks); return Collections.unmodifiableSet(tasks);
} }
@Override @Override

View File

@ -61,17 +61,17 @@ import com.google.common.collect.Sets;
"configuration", "configuration",
"isDeployed" "isDeployed"
}) })
public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> extends ResourceType<T> { public class VAppNetworkConfiguration extends ResourceType<VAppNetworkConfiguration> {
public static <T extends VAppNetworkConfiguration<T>> Builder<T> builder() { public static <T extends VAppNetworkConfiguration> Builder builder() {
return new Builder<T>(); return new Builder();
} }
@Override @Override
public Builder<T> toBuilder() { public Builder toBuilder() {
return new Builder<T>().fromVAppNetworkConfiguration(this); return new Builder().fromVAppNetworkConfiguration(this);
} }
public static class Builder<T extends VAppNetworkConfiguration<T>> extends ResourceType.Builder<T> { public static class Builder extends ResourceType.Builder<VAppNetworkConfiguration> {
private String description; private String description;
private NetworkConfiguration configuration; private NetworkConfiguration configuration;
@ -81,7 +81,7 @@ public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> ext
/** /**
* @see VAppNetworkConfiguration#getDescription() * @see VAppNetworkConfiguration#getDescription()
*/ */
public Builder<T> description(String description) { public Builder description(String description) {
this.description = description; this.description = description;
return this; return this;
} }
@ -89,7 +89,7 @@ public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> ext
/** /**
* @see VAppNetworkConfiguration#getConfiguration() * @see VAppNetworkConfiguration#getConfiguration()
*/ */
public Builder<T> configuration(NetworkConfiguration configuration) { public Builder configuration(NetworkConfiguration configuration) {
this.configuration = configuration; this.configuration = configuration;
return this; return this;
} }
@ -97,7 +97,7 @@ public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> ext
/** /**
* @see VAppNetworkConfiguration#isDeployed() * @see VAppNetworkConfiguration#isDeployed()
*/ */
public Builder<T> isDeployed(Boolean isDeployed) { public Builder isDeployed(Boolean isDeployed) {
this.isDeployed = isDeployed; this.isDeployed = isDeployed;
return this; return this;
} }
@ -105,14 +105,14 @@ public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> ext
/** /**
* @see VAppNetworkConfiguration#getNetworkName() * @see VAppNetworkConfiguration#getNetworkName()
*/ */
public Builder<T> networkName(String networkName) { public Builder networkName(String networkName) {
this.networkName = networkName; this.networkName = networkName;
return this; return this;
} }
public VAppNetworkConfiguration<T> build() { public VAppNetworkConfiguration build() {
return new VAppNetworkConfiguration<T>(href, type, links, return new VAppNetworkConfiguration(href, type, links,
description, configuration, isDeployed, networkName); description, configuration, isDeployed, networkName);
} }
@ -121,7 +121,7 @@ public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> ext
* @see ResourceType#getHref() * @see ResourceType#getHref()
*/ */
@Override @Override
public Builder<T> href(URI href) { public Builder href(URI href) {
super.href(href); super.href(href);
return this; return this;
} }
@ -130,7 +130,7 @@ public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> ext
* @see ResourceType#getType() * @see ResourceType#getType()
*/ */
@Override @Override
public Builder<T> type(String type) { public Builder type(String type) {
super.type(type); super.type(type);
return this; return this;
} }
@ -139,7 +139,7 @@ public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> ext
* @see ResourceType#getLinks() * @see ResourceType#getLinks()
*/ */
@Override @Override
public Builder<T> links(Set<Link> links) { public Builder links(Set<Link> links) {
super.links(Sets.newLinkedHashSet(checkNotNull(links, "links"))); super.links(Sets.newLinkedHashSet(checkNotNull(links, "links")));
return this; return this;
} }
@ -148,7 +148,7 @@ public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> ext
* @see ResourceType#getLinks() * @see ResourceType#getLinks()
*/ */
@Override @Override
public Builder<T> link(Link link) { public Builder link(Link link) {
super.link(link); super.link(link);
return this; return this;
} }
@ -157,11 +157,11 @@ public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> ext
* {@inheritDoc} * {@inheritDoc}
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Builder<T> fromResourceType(ResourceType<T> in) { public Builder fromResourceType(ResourceType<VAppNetworkConfiguration> in) {
return Builder.class.cast(super.fromResourceType(in)); return Builder.class.cast(super.fromResourceType(in));
} }
public Builder<T> fromVAppNetworkConfiguration(VAppNetworkConfiguration<T> in) { public Builder fromVAppNetworkConfiguration(VAppNetworkConfiguration in) {
return fromResourceType(in) return fromResourceType(in)
.description(in.getDescription()) .description(in.getDescription())
.configuration(in.getConfiguration()) .configuration(in.getConfiguration())
@ -238,7 +238,7 @@ public class VAppNetworkConfiguration<T extends VAppNetworkConfiguration<T>> ext
return true; return true;
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
VAppNetworkConfiguration<?> that = VAppNetworkConfiguration.class.cast(o); VAppNetworkConfiguration that = VAppNetworkConfiguration.class.cast(o);
return equal(description, that.description) && return equal(description, that.description) &&
equal(configuration, that.configuration) && equal(configuration, that.configuration) &&
equal(isDeployed, that.isDeployed) && equal(isDeployed, that.isDeployed) &&

View File

@ -20,14 +20,12 @@ package org.jclouds.vcloud.director.v1_5.domain.cim;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableList; import com.google.common.collect.*;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
/** /**
* *
@ -238,7 +236,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* @see ResourceAllocationSettingData#getConnections * @see ResourceAllocationSettingData#getConnections
*/ */
public Builder connections(List<String> connections) { public Builder connections(List<String> connections) {
this.connections.addAll(checkNotNull(connections, "connections")); this.connections = Lists.newArrayList(checkNotNull(connections, "connections"));
return this; return this;
} }
@ -246,7 +244,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* @see ResourceAllocationSettingData#getHostResources * @see ResourceAllocationSettingData#getHostResources
*/ */
public Builder hostResources(List<String> hostResources) { public Builder hostResources(List<String> hostResources) {
this.hostResources.addAll(checkNotNull(hostResources, "hostResources")); this.hostResources = Lists.newArrayList(checkNotNull(hostResources, "hostResources"));
return this; return this;
} }
@ -665,7 +663,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* network or switch port. * network or switch port.
*/ */
public List<String> getConnections() { public List<String> 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. * based on host resources that are identified by element values.
*/ */
public List<String> getHostResources() { public List<String> getHostResources() {
return hostResources; return Collections.unmodifiableList(hostResources);
} }
@Override @Override