From de16cb00bee783f3b9c584ee5d62cda5498b7ae5 Mon Sep 17 00:00:00 2001 From: Aled Sage Date: Tue, 13 Mar 2012 15:18:12 +0000 Subject: [PATCH] Added builder for RASD and CIMResourceAllocationSettingDataType --- .../CIMResourceAllocationSettingDataType.java | 287 ++++++++++++++++-- .../v1_5/domain/ovf/Configuration.java | 8 +- .../director/v1_5/domain/ovf/DiskSection.java | 2 +- .../vcloud/director/v1_5/domain/ovf/RASD.java | 197 ++++++------ 4 files changed, 373 insertions(+), 121 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CIMResourceAllocationSettingDataType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CIMResourceAllocationSettingDataType.java index 57772e3d35..40876bc042 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CIMResourceAllocationSettingDataType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/cim/CIMResourceAllocationSettingDataType.java @@ -40,63 +40,296 @@ import javax.xml.namespace.QName; @XmlType(name = "CIM_ResourceAllocationSettingData_Type", namespace = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData") public class CIMResourceAllocationSettingDataType { + // TODO Add toString, hashCode and equals + + public static Builder builder() { + return new ConcreteBuilder(); + } + + public Builder toBuilder() { + return builder().fromCIMResourceAllocationSettingDataType(this); + } + + public static class Builder> { + private CimString address; + private CimString addressOnParent; + private CimString allocationUnits; + private CimBoolean automaticAllocation; + private CimBoolean automaticDeallocation; + private ResourceAllocationCaption caption; + private ResourceAllocationChangeableType changeableType; + private CimString configurationName; + private List connection; + private ConsumerVisibility consumerVisibility; + private CimString description; + private CimString elementName; + private CimUnsignedLong generation; + private List hostResource; + private CimString instanceID; + private CimUnsignedLong limit; + private MappingBehavior mappingBehavior; + private CimString otherResourceType; + private CimString parent; + private CimString poolID; + private CimUnsignedLong reservation; + private CimString resourceSubType; + private ResourceType resourceType; + private CimUnsignedLong virtualQuantity; + private CimString virtualQuantityUnits; + private CimUnsignedInt weight; + private List any; + private Map otherAttributes = new HashMap(); + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + + public B address(CimString val) { + this.address = val; + return self(); + } + public B addressOnParent(CimString val) { + this.addressOnParent = val; + return self(); + } + public B allocationUnits(CimString val) { + this.allocationUnits = val; + return self(); + } + public B automaticAllocation(CimBoolean val) { + this.automaticAllocation = val; + return self(); + } + public B automaticDeallocation(CimBoolean val) { + this.automaticDeallocation = val; + return self(); + } + public B caption(ResourceAllocationCaption val) { + this.caption = val; + return self(); + } + public B changeableType(ResourceAllocationChangeableType val) { + this.changeableType = val; + return self(); + } + public B configurationName(CimString val) { + this.configurationName = val; + return self(); + } + public B connection(List val) { + this.connection = val; + return self(); + } + public B consumerVisibility(ConsumerVisibility val) { + this.consumerVisibility = val; + return self(); + } + public B description(CimString val) { + this.description = val; + return self(); + } + public B elementName(CimString val) { + this.elementName = val; + return self(); + } + public B generation(CimUnsignedLong val) { + this.generation = val; + return self(); + } + public B hostResource(List val) { + this.hostResource = val; + return self(); + } + public B instanceID(CimString val) { + this.instanceID = val; + return self(); + } + public B limit(CimUnsignedLong val) { + this.limit = val; + return self(); + } + public B mappingBehavior(MappingBehavior val) { + this.mappingBehavior = val; + return self(); + } + public B otherResourceType(CimString val) { + this.otherResourceType = val; + return self(); + } + public B parent(CimString val) { + this.parent = val; + return self(); + } + public B poolID(CimString val) { + this.poolID = val; + return self(); + } + public B reservation(CimUnsignedLong val) { + this.reservation = val; + return self(); + } + public B resourceSubType(CimString val) { + this.resourceSubType = val; + return self(); + } + public B resourceType(ResourceType val) { + this.resourceType = val; + return self(); + } + public B virtualQuantity(CimUnsignedLong val) { + this.virtualQuantity = val; + return self(); + } + public B virtualQuantityUnits(CimString val) { + this.virtualQuantityUnits = val; + return self(); + } + public B weight(CimUnsignedInt val) { + this.weight = val; + return self(); + } + public B any(List val) { + this.any = val; + return self(); + } + public B otherAttributes(Map val) { + this.otherAttributes = val; + return self(); + } + + public B fromCIMResourceAllocationSettingDataType(CIMResourceAllocationSettingDataType val) { + return self().address(val.getAddress()). + addressOnParent(val.getAddressOnParent()). + allocationUnits(val.getAllocationUnits()). + allocationUnits(val.getAllocationUnits()). + automaticAllocation(val.getAutomaticAllocation()). + automaticDeallocation(val.getAutomaticDeallocation()). + caption(val.getCaption()). + changeableType(val.getChangeableType()). + configurationName(val.getConfigurationName()). + connection(val.getConnection()). + consumerVisibility(val.getConsumerVisibility()). + description(val.getDescription()). + elementName(val.getElementName()). + generation(val.getGeneration()). + hostResource(val.getHostResource()). + instanceID(val.getInstanceID()). + limit(val.getLimit()). + mappingBehavior(val.getMappingBehavior()). + otherResourceType(val.getOtherResourceType()). + parent(val.getParent()). + poolID(val.getPoolID()). + reservation(val.getReservation()). + resourceSubType(val.getResourceSubType()). + resourceType(val.getResourceType()). + virtualQuantity(val.getVirtualQuantity()). + virtualQuantityUnits(val.getVirtualQuantityUnits()). + weight(val.getWeight()). + any(val.getAny()). + otherAttributes(val.getOtherAttributes()); + } + + public CIMResourceAllocationSettingDataType build() { + return new CIMResourceAllocationSettingDataType(this); + } + } + + private static class ConcreteBuilder extends Builder { + } + @XmlElement(name = "Address", nillable = true) - protected CimString address; + private CimString address; @XmlElement(name = "AddressOnParent", nillable = true) - protected CimString addressOnParent; + private CimString addressOnParent; @XmlElement(name = "AllocationUnits", nillable = true) - protected CimString allocationUnits; + private CimString allocationUnits; @XmlElement(name = "AutomaticAllocation", nillable = true) - protected CimBoolean automaticAllocation; + private CimBoolean automaticAllocation; @XmlElement(name = "AutomaticDeallocation", nillable = true) - protected CimBoolean automaticDeallocation; + private CimBoolean automaticDeallocation; @XmlElementRef(name = "Caption", namespace = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData", type = ResourceAllocationCaption.class) - protected ResourceAllocationCaption caption; + private ResourceAllocationCaption caption; @XmlElementRef(name = "ChangeableType", namespace = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData", type = ResourceAllocationChangeableType.class) - protected ResourceAllocationChangeableType changeableType; + private ResourceAllocationChangeableType changeableType; @XmlElement(name = "ConfigurationName", nillable = true) - protected CimString configurationName; + private CimString configurationName; @XmlElement(name = "Connection", nillable = true) - protected List connection; + private List connection; @XmlElement(name = "ConsumerVisibility", nillable = true) - protected ConsumerVisibility consumerVisibility; + private ConsumerVisibility consumerVisibility; @XmlElement(name = "Description", nillable = true) - protected CimString description; + private CimString description; @XmlElement(name = "ElementName", required = true) - protected CimString elementName; + private CimString elementName; @XmlElement(name = "Generation", nillable = true) - protected CimUnsignedLong generation; + private CimUnsignedLong generation; @XmlElement(name = "HostResource", nillable = true) - protected List hostResource; + private List hostResource; @XmlElement(name = "InstanceID", required = true) - protected CimString instanceID; + private CimString instanceID; @XmlElement(name = "Limit", nillable = true) - protected CimUnsignedLong limit; + private CimUnsignedLong limit; @XmlElement(name = "MappingBehavior", nillable = true) - protected MappingBehavior mappingBehavior; + private MappingBehavior mappingBehavior; @XmlElement(name = "OtherResourceType", nillable = true) - protected CimString otherResourceType; + private CimString otherResourceType; @XmlElement(name = "Parent", nillable = true) - protected CimString parent; + private CimString parent; @XmlElement(name = "PoolID", nillable = true) - protected CimString poolID; + private CimString poolID; @XmlElement(name = "Reservation", nillable = true) - protected CimUnsignedLong reservation; + private CimUnsignedLong reservation; @XmlElement(name = "ResourceSubType", nillable = true) - protected CimString resourceSubType; + private CimString resourceSubType; @XmlElement(name = "ResourceType", nillable = true) - protected ResourceType resourceType; + private ResourceType resourceType; @XmlElement(name = "VirtualQuantity", nillable = true) - protected CimUnsignedLong virtualQuantity; + private CimUnsignedLong virtualQuantity; @XmlElement(name = "VirtualQuantityUnits", nillable = true) - protected CimString virtualQuantityUnits; + private CimString virtualQuantityUnits; @XmlElement(name = "Weight", nillable = true) - protected CimUnsignedInt weight; + private CimUnsignedInt weight; @XmlAnyElement(lax = true) - protected List any; + private List any; @XmlAnyAttribute private Map otherAttributes = new HashMap(); + protected CIMResourceAllocationSettingDataType() { + // For JAXB + } + + protected CIMResourceAllocationSettingDataType(Builder builder) { + this.address = builder.address; + this.addressOnParent = builder.addressOnParent; + this.allocationUnits = builder.allocationUnits; + this.automaticAllocation = builder.automaticAllocation; + this.automaticDeallocation = builder.automaticDeallocation; + this.caption = builder.caption; + this.changeableType = builder.changeableType; + this.configurationName = builder.configurationName; + this.connection = builder.connection; + this.consumerVisibility = builder.consumerVisibility; + this.description = builder.description; + this.elementName = builder.elementName; + this.generation = builder.generation; + this.hostResource = builder.hostResource; + this.instanceID = builder.instanceID; + this.limit = builder.limit; + this.mappingBehavior = builder.mappingBehavior; + this.otherResourceType = builder.otherResourceType; + this.parent = builder.parent; + this.poolID = builder.poolID; + this.reservation = builder.reservation; + this.resourceSubType = builder.resourceSubType; + this.resourceType = builder.resourceType; + this.virtualQuantity = builder.virtualQuantity; + this.virtualQuantityUnits = builder.virtualQuantityUnits; + this.weight = builder.weight; + this.any = builder.any; + this.otherAttributes = builder.otherAttributes; + } + /** * Gets the value of the address property. * diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Configuration.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Configuration.java index e826eba2ed..dcc7c2d3aa 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Configuration.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/Configuration.java @@ -39,10 +39,10 @@ public class Configuration { } public static class Builder { - protected String id; - protected boolean isDefault; - protected String label; - protected String description; + private String id; + private boolean isDefault; + private String label; + private String description; /** * @see Configuration#getId diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/DiskSection.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/DiskSection.java index 8258771c30..21fb33d30c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/DiskSection.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/DiskSection.java @@ -60,7 +60,7 @@ public class DiskSection extends SectionType { } public static class Builder extends SectionType.Builder { - protected Set disks = Sets.newLinkedHashSet(); + private Set disks = Sets.newLinkedHashSet(); /** * @see DiskSection#getDisks diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/RASD.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/RASD.java index d1fcf624ee..1dbf024ed0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/RASD.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ovf/RASD.java @@ -1,114 +1,133 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.02.08 at 02:47:44 PM GMT -// - - +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.jclouds.vcloud.director.v1_5.domain.ovf; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS; + import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlType; import org.jclouds.vcloud.director.v1_5.domain.cim.CIMResourceAllocationSettingDataType; - /** * Wrapper for CIM_ResourceAllocationSettingData_Type - * + * *
  * <complexType name="RASD_Type" />
  * 
- * + * * @author grkvlt@apache.org */ @XmlType(name = "RASD_Type") public class RASD extends CIMResourceAllocationSettingDataType { - @XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1") - protected Boolean required; - @XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1") - protected String configuration; - @XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1") - protected String bound; + // TODO Add toString, hashCode and equals - /** - * Gets the value of the required property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public boolean isRequired() { - if (required == null) { - return true; - } else { - return required; - } - } + public static Builder builder() { + return new ConcreteBuilder(); + } - /** - * Sets the value of the required property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setRequired(Boolean value) { - this.required = value; - } + @Override + public Builder toBuilder() { + return builder().fromRASD(this); + } - /** - * Gets the value of the configuration property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getConfiguration() { - return configuration; - } + public static class Builder> extends CIMResourceAllocationSettingDataType.Builder { - /** - * Sets the value of the configuration property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setConfiguration(String value) { - this.configuration = value; - } + private Boolean required; + private String configuration; + private String bound; - /** - * Gets the value of the bound property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getBound() { - return bound; - } + public B required(Boolean val) { + this.required = val; + return self(); + } - /** - * Sets the value of the bound property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBound(String value) { - this.bound = value; - } + public B configuration(String val) { + this.configuration = val; + return self(); + } + public B bound(String val) { + this.bound = val; + return self(); + } + + public B fromRASD(RASD val) { + return fromCIMResourceAllocationSettingDataType(val).required(val.isRequired()).configuration(val.getConfiguration()).bound(val.getBound()); + } + + @Override + public RASD build() { + return new RASD(this); + } + } + + private static class ConcreteBuilder extends Builder { + } + + @XmlAttribute(namespace = VCLOUD_OVF_NS) + private Boolean required; + @XmlAttribute(namespace = VCLOUD_OVF_NS) + private String configuration; + @XmlAttribute(namespace = VCLOUD_OVF_NS) + private String bound; + + protected RASD() { + // For JAXB + } + + protected RASD(Builder builder) { + super(builder); + this.required = builder.required; + this.configuration = builder.configuration; + this.bound = builder.bound; + } + + /** + * Gets the value of the required property. + * + * @return possible object is {@link Boolean } + */ + public boolean isRequired() { + if (required == null) { + return true; + } else { + return required; + } + } + + /** + * Gets the value of the configuration property. + * + * @return possible object is {@link String } + */ + public String getConfiguration() { + return configuration; + } + + /** + * Gets the value of the bound property. + * + * @return possible object is {@link String } + */ + public String getBound() { + return bound; + } }