domain object tweaks

This commit is contained in:
danikov 2012-02-14 12:13:44 +00:00
parent e50dd9f2eb
commit b8c0670cad
6 changed files with 113 additions and 69 deletions

View File

@ -20,8 +20,8 @@
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.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
@ -29,6 +29,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
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 org.testng.collections.Lists;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -58,7 +60,7 @@ import com.google.common.base.Objects;
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AvailableNetworks", propOrder = { @XmlType(name = "AvailableNetworks", propOrder = {
"network" "networks"
}) })
public class AvailableNetworks { public class AvailableNetworks {
public static Builder builder() { public static Builder builder() {
@ -71,25 +73,32 @@ public class AvailableNetworks {
public static class Builder { public static class Builder {
private List<Reference> network; private List<Reference> networks = Lists.newArrayList();
/** /**
* @see AvailableNetworks#getNetwork() * @see AvailableNetworks#getNetworks()
*/ */
public Builder network(List<Reference> network) { public Builder networks(List<Reference> networks) {
this.network = network; this.networks = Lists.newArrayList(checkNotNull(networks, "networks"));
return this; return this;
} }
/**
* @see AvailableNetworks#getNetworks()
*/
public Builder network(Reference network) {
networks.add(checkNotNull(network, "network"));
return this;
}
public AvailableNetworks build() { public AvailableNetworks build() {
AvailableNetworks availableNetworks = new AvailableNetworks(network); AvailableNetworks availableNetworks = new AvailableNetworks(networks);
return availableNetworks; return availableNetworks;
} }
public Builder fromAvailableNetworks(AvailableNetworks in) { public Builder fromAvailableNetworks(AvailableNetworks in) {
return network(in.getNetwork()); return networks(in.getNetworks());
} }
} }
@ -97,13 +106,13 @@ public class AvailableNetworks {
// For JAXB and builder use // For JAXB and builder use
} }
private AvailableNetworks(List<Reference> network) { private AvailableNetworks(List<Reference> networks) {
this.network = network; this.networks = networks;
} }
@XmlElement(name = "Network") @XmlElement(name = "Network")
protected List<Reference> network; protected List<Reference> networks;
/** /**
* Gets the value of the network property. * Gets the value of the network property.
@ -127,11 +136,11 @@ public class AvailableNetworks {
* *
* *
*/ */
public List<Reference> getNetwork() { public List<Reference> getNetworks() {
if (network == null) { if (networks == null) {
network = new ArrayList<Reference>(); networks = Lists.newArrayList();
} }
return this.network; return this.networks;
} }
@Override @Override
@ -141,18 +150,18 @@ public class AvailableNetworks {
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
AvailableNetworks that = AvailableNetworks.class.cast(o); AvailableNetworks that = AvailableNetworks.class.cast(o);
return equal(network, that.network); return equal(networks, that.networks);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(network); return Objects.hashCode(networks);
} }
@Override @Override
public String toString() { public String toString() {
return Objects.toStringHelper("") return Objects.toStringHelper("")
.add("network", network).toString(); .add("network", networks).toString();
} }
} }

View File

@ -45,8 +45,8 @@ import com.google.common.base.Objects;
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType"> * &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="Units" type="{http://www.w3.org/2001/XMLSchema}string"/> * &lt;element name="Units" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="Allocated" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/> * &lt;element name="Allocated" type="{http://www.w3.org/2001/XMLSchema}Long" minOccurs="0"/>
* &lt;element name="Limit" type="{http://www.w3.org/2001/XMLSchema}long"/> * &lt;element name="Limit" type="{http://www.w3.org/2001/XMLSchema}Long"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/> * &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension> * &lt;/extension>
@ -79,7 +79,7 @@ public class CapacityType<T extends CapacityType<T>> {
protected String units; protected String units;
protected Long allocated; protected Long allocated;
protected long limit; protected Long limit;
/** /**
* @see CapacityType#getUnits() * @see CapacityType#getUnits()
@ -100,7 +100,7 @@ public class CapacityType<T extends CapacityType<T>> {
/** /**
* @see CapacityType#getLimit() * @see CapacityType#getLimit()
*/ */
public Builder<T> limit(long limit) { public Builder<T> limit(Long limit) {
this.limit = limit; this.limit = limit;
return this; return this;
} }
@ -137,7 +137,7 @@ public class CapacityType<T extends CapacityType<T>> {
@XmlElement(name = "Allocated") @XmlElement(name = "Allocated")
protected Long allocated; protected Long allocated;
@XmlElement(name = "Limit") @XmlElement(name = "Limit")
protected long limit; protected Long limit;
/** /**
* Gets the value of the units property. * Gets the value of the units property.
@ -191,7 +191,7 @@ public class CapacityType<T extends CapacityType<T>> {
* Gets the value of the limit property. * Gets the value of the limit property.
* *
*/ */
public long getLimit() { public Long getLimit() {
return limit; return limit;
} }
@ -199,7 +199,7 @@ public class CapacityType<T extends CapacityType<T>> {
* Sets the value of the limit property. * Sets the value of the limit property.
* *
*/ */
public void setLimit(long value) { public void setLimit(Long value) {
this.limit = value; this.limit = value;
} }

View File

@ -43,8 +43,8 @@ import com.google.common.base.Objects;
* &lt;complexContent> * &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}CapacityType"> * &lt;extension base="{http://www.vmware.com/vcloud/v1.5}CapacityType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="Used" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/> * &lt;element name="Used" type="{http://www.w3.org/2001/XMLSchema}Long" minOccurs="0"/>
* &lt;element name="Overhead" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/> * &lt;element name="Overhead" type="{http://www.w3.org/2001/XMLSchema}Long" minOccurs="0"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/> * &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension> * &lt;/extension>
@ -121,7 +121,7 @@ public class CapacityWithUsage extends CapacityType<CapacityWithUsage>
/** /**
* @see CapacityType#getLimit() * @see CapacityType#getLimit()
*/ */
public Builder limit(long limit) { public Builder limit(Long limit) {
this.limit = limit; this.limit = limit;
return this; return this;
} }

View File

@ -20,8 +20,8 @@
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.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
@ -29,6 +29,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
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 org.testng.collections.Lists;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -46,7 +48,7 @@ import com.google.common.base.Objects;
* &lt;complexContent> * &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType"> * &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
* &lt;sequence> * &lt;sequence>
* &lt;element name="ResourceEntity" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType<?>Type" maxOccurs="unbounded" minOccurs="0"/> * &lt;element name="ResourceEntity" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/> * &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension> * &lt;/extension>
@ -58,7 +60,7 @@ import com.google.common.base.Objects;
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ResourceEntities", propOrder = { @XmlType(name = "ResourceEntities", propOrder = {
"resourceEntity" "resourceEntities"
}) })
public class ResourceEntities { public class ResourceEntities {
public static Builder builder() { public static Builder builder() {
@ -71,25 +73,32 @@ public class ResourceEntities {
public static class Builder { public static class Builder {
private List<ReferenceType<?>> resourceEntity; private List<Reference> resourceEntities = Lists.newArrayList();
/** /**
* @see ResourceEntities#getResourceEntity() * @see ResourceEntities#getResourceEntities()
*/ */
public Builder resourceEntity(List<ReferenceType<?>> resourceEntity) { public Builder resourceEntities(List<Reference> resourceEntities) {
this.resourceEntity = resourceEntity; this.resourceEntities = Lists.newArrayList(checkNotNull(resourceEntities, "resourceEntities"));
return this; return this;
} }
/**
* @see ResourceEntities#getResourceEntities()
*/
public Builder resourceEntity(Reference resourceEntity) {
resourceEntities.add(checkNotNull(resourceEntity, "resourceEntity"));
return this;
}
public ResourceEntities build() { public ResourceEntities build() {
ResourceEntities resourceEntities = new ResourceEntities(resourceEntity); ResourceEntities resourceEntities = new ResourceEntities(this.resourceEntities);
return resourceEntities; return resourceEntities;
} }
public Builder fromResourceEntities(ResourceEntities in) { public Builder fromResourceEntities(ResourceEntities in) {
return resourceEntity(in.getResourceEntity()); return resourceEntities(in.getResourceEntities());
} }
} }
@ -97,13 +106,13 @@ public class ResourceEntities {
// For JAXB and builder use // For JAXB and builder use
} }
private ResourceEntities(List<ReferenceType<?>> resourceEntity) { private ResourceEntities(List<Reference> resourceEntity) {
this.resourceEntity = resourceEntity; this.resourceEntities = resourceEntity;
} }
@XmlElement(name = "ResourceEntity") @XmlElement(name = "ResourceEntity")
protected List<ReferenceType<?>> resourceEntity; protected List<Reference> resourceEntities;
/** /**
* Gets the value of the resourceEntity property. * Gets the value of the resourceEntity property.
@ -123,15 +132,15 @@ public class ResourceEntities {
* *
* <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 ReferenceType<?>Type } * {@link ReferenceType }
* *
* *
*/ */
public List<ReferenceType<?>> getResourceEntity() { public List<Reference> getResourceEntities() {
if (resourceEntity == null) { if (resourceEntities == null) {
resourceEntity = new ArrayList<ReferenceType<?>>(); resourceEntities = Lists.newArrayList();
} }
return this.resourceEntity; return this.resourceEntities;
} }
@Override @Override
@ -141,18 +150,18 @@ public class ResourceEntities {
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
ResourceEntities that = ResourceEntities.class.cast(o); ResourceEntities that = ResourceEntities.class.cast(o);
return equal(resourceEntity, that.resourceEntity); return equal(resourceEntities, that.resourceEntities);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(resourceEntity); return Objects.hashCode(resourceEntities);
} }
@Override @Override
public String toString() { public String toString() {
return Objects.toStringHelper("") return Objects.toStringHelper("")
.add("resourceEntity", resourceEntity).toString(); .add("resourceEntity", resourceEntities).toString();
} }
} }

View File

@ -20,8 +20,8 @@
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.ArrayList;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
@ -29,6 +29,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
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 org.testng.collections.Lists;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -58,7 +60,7 @@ import com.google.common.base.Objects;
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SupportedHardwareVersions", propOrder = { @XmlType(name = "SupportedHardwareVersions", propOrder = {
"supportedHardwareVersion" "supportedHardwareVersions"
}) })
public class SupportedHardwareVersions { public class SupportedHardwareVersions {
public static Builder builder() { public static Builder builder() {
@ -71,25 +73,32 @@ public class SupportedHardwareVersions {
public static class Builder { public static class Builder {
private List<String> supportedHardwareVersion; private List<String> supportedHardwareVersions = Lists.newArrayList();
/** /**
* @see SupportedHardwareVersions#getSupportedHardwareVersion() * @see SupportedHardwareVersions#getSupportedHardwareVersions()
*/ */
public Builder supportedHardwareVersion(List<String> supportedHardwareVersion) { public Builder supportedHardwareVersions(List<String> supportedHardwareVersions) {
this.supportedHardwareVersion = supportedHardwareVersion; this.supportedHardwareVersions = Lists.newArrayList(checkNotNull(supportedHardwareVersions, "supportedHardwareVersions"));
return this;
}
/**
* @see SupportedHardwareVersions#getSupportedHardwareVersions()
*/
public Builder supportedHardwareVersion(String supportedHardwareVersion) {
supportedHardwareVersions.add(checkNotNull(supportedHardwareVersion, "supportedHardwareVersion"));
return this; return this;
} }
public SupportedHardwareVersions build() { public SupportedHardwareVersions build() {
SupportedHardwareVersions supportedHardwareVersions = new SupportedHardwareVersions(supportedHardwareVersion); SupportedHardwareVersions supportedHardwareVersions = new SupportedHardwareVersions(this.supportedHardwareVersions);
return supportedHardwareVersions; return supportedHardwareVersions;
} }
public Builder fromSupportedHardwareVersions(SupportedHardwareVersions in) { public Builder fromSupportedHardwareVersions(SupportedHardwareVersions in) {
return supportedHardwareVersion(in.getSupportedHardwareVersion()); return supportedHardwareVersions(in.getSupportedHardwareVersions());
} }
} }
@ -97,13 +106,13 @@ public class SupportedHardwareVersions {
// For JAXB and builder use // For JAXB and builder use
} }
private SupportedHardwareVersions(List<String> supportedHardwareVersion) { private SupportedHardwareVersions(List<String> supportedHardwareVersions) {
this.supportedHardwareVersion = supportedHardwareVersion; this.supportedHardwareVersions = supportedHardwareVersions;
} }
@XmlElement(name = "SupportedHardwareVersion") @XmlElement(name = "SupportedHardwareVersion")
protected List<String> supportedHardwareVersion; protected List<String> supportedHardwareVersions;
/** /**
* Gets the value of the supportedHardwareVersion property. * Gets the value of the supportedHardwareVersion property.
@ -127,11 +136,11 @@ public class SupportedHardwareVersions {
* *
* *
*/ */
public List<String> getSupportedHardwareVersion() { public List<String> getSupportedHardwareVersions() {
if (supportedHardwareVersion == null) { if (supportedHardwareVersions == null) {
supportedHardwareVersion = new ArrayList<String>(); supportedHardwareVersions = Lists.newArrayList();
} }
return this.supportedHardwareVersion; return this.supportedHardwareVersions;
} }
@Override @Override
@ -141,18 +150,18 @@ public class SupportedHardwareVersions {
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
SupportedHardwareVersions that = SupportedHardwareVersions.class.cast(o); SupportedHardwareVersions that = SupportedHardwareVersions.class.cast(o);
return equal(supportedHardwareVersion, that.supportedHardwareVersion); return equal(supportedHardwareVersions, that.supportedHardwareVersions);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(supportedHardwareVersion); return Objects.hashCode(supportedHardwareVersions);
} }
@Override @Override
public String toString() { public String toString() {
return Objects.toStringHelper("") return Objects.toStringHelper("")
.add("supportedHardwareVersion", supportedHardwareVersion).toString(); .add("supportedHardwareVersion", supportedHardwareVersions).toString();
} }
} }

View File

@ -29,6 +29,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
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.XmlSeeAlso; import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
@ -71,7 +72,8 @@ import com.google.common.collect.Sets;
* *
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Vdc", propOrder = { @XmlRootElement(name = "Vdc")
@XmlType(propOrder = {
"allocationModel", "allocationModel",
"storageCapacity", "storageCapacity",
"computeCapacity", "computeCapacity",
@ -217,7 +219,22 @@ public class Vdc
vdc.setStatus(status); vdc.setStatus(status);
return vdc; return vdc;
} }
/**
* @see EntityType#getName()
*/
public Builder name(String name) {
super.name(name);
return this;
}
/**
* @see EntityType#getDescription()
*/
public Builder description(String description) {
super.description(description);
return this;
}
/** /**
* @see EntityType#getId() * @see EntityType#getId()