mirror of https://github.com/apache/jclouds.git
Domain object cleanup: add builders, hashCode and equals
This commit is contained in:
parent
392c836688
commit
113b8fc7df
|
@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlAnyElement;
|
||||||
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.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;
|
||||||
|
@ -77,7 +78,7 @@ public class RuntimeInfoSection extends SectionType<RuntimeInfoSection> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RuntimeInfoSection build() {
|
public RuntimeInfoSection build() {
|
||||||
RuntimeInfoSection runtimeInfoSection = new RuntimeInfoSection(vmWareTools, any);
|
RuntimeInfoSection runtimeInfoSection = new RuntimeInfoSection(info, required, vmWareTools, any);
|
||||||
return runtimeInfoSection;
|
return runtimeInfoSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,16 +98,17 @@ public class RuntimeInfoSection extends SectionType<RuntimeInfoSection> {
|
||||||
// For JAXB and builder use
|
// For JAXB and builder use
|
||||||
}
|
}
|
||||||
|
|
||||||
public RuntimeInfoSection(VMWareTools vmWareTools, List<Object> any) {
|
public RuntimeInfoSection(@Nullable String info, @Nullable Boolean required, VMWareTools vmWareTools, List<Object> any) {
|
||||||
|
super(info, required);
|
||||||
this.vmWareTools = vmWareTools;
|
this.vmWareTools = vmWareTools;
|
||||||
this.any = any;
|
this.any = any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@XmlElement(name = "VMWareTools")
|
@XmlElement(name = "VMWareTools")
|
||||||
protected VMWareTools vmWareTools;
|
private VMWareTools vmWareTools;
|
||||||
@XmlAnyElement(lax = true)
|
@XmlAnyElement(lax = true)
|
||||||
protected List<Object> any = Lists.newArrayList();
|
private List<Object> any = Lists.newArrayList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the vmWareTools property.
|
* Gets the value of the vmWareTools property.
|
||||||
|
|
|
@ -19,11 +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 javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.XmlValue;
|
import javax.xml.bind.annotation.XmlValue;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ticket for accessing the console of a VM.
|
* The ticket for accessing the console of a VM.
|
||||||
*
|
*
|
||||||
|
@ -35,8 +39,44 @@ import javax.xml.bind.annotation.XmlValue;
|
||||||
@XmlType(name = "ScreenTicket")
|
@XmlType(name = "ScreenTicket")
|
||||||
public class ScreenTicket {
|
public class ScreenTicket {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return builder().fromScreenTicket(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VmQuestionAnswer#getChoiceId()
|
||||||
|
*/
|
||||||
|
public Builder value(String value) {
|
||||||
|
this.value = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScreenTicket build() {
|
||||||
|
return new ScreenTicket(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromScreenTicket(ScreenTicket in) {
|
||||||
|
return value(in.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ScreenTicket() {
|
||||||
|
// For JAXB
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScreenTicket(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
@XmlValue
|
@XmlValue
|
||||||
protected String value;
|
private String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the value property.
|
* Gets the value of the value property.
|
||||||
|
@ -44,4 +84,24 @@ public class ScreenTicket {
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
ScreenTicket that = ScreenTicket.class.cast(o);
|
||||||
|
return equal(this.value, that.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return Objects.toStringHelper("").add("value", value).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,24 @@
|
||||||
|
|
||||||
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 org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAnyElement;
|
import javax.xml.bind.annotation.XmlAnyElement;
|
||||||
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 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 org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSectionItem;
|
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSectionItem;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType.Builder;
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the order in which entities in a VirtualSystemCollection are powered on and shut down
|
* Specifies the order in which entities in a VirtualSystemCollection are powered on and shut down
|
||||||
|
@ -30,16 +36,60 @@ import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType.Builder;
|
||||||
@XmlRootElement(name = "StartupSection", namespace = VCLOUD_OVF_NS)
|
@XmlRootElement(name = "StartupSection", namespace = VCLOUD_OVF_NS)
|
||||||
public class StartupSection extends SectionType<StartupSection> {
|
public class StartupSection extends SectionType<StartupSection> {
|
||||||
|
|
||||||
/** @see org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType#toBuilder() */
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType.Builder<StartupSection> toBuilder() {
|
public Builder toBuilder() {
|
||||||
return null;
|
return builder().fromStartupSection(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends SectionType.Builder<StartupSection> {
|
||||||
|
|
||||||
|
private List<StartupSectionItem> item = Collections.emptyList();
|
||||||
|
private List<Object> any = Collections.emptyList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see StartupSection#getItem()
|
||||||
|
*/
|
||||||
|
public Builder item(List<StartupSectionItem> item) {
|
||||||
|
this.item = item;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see StartupSection#getAny()
|
||||||
|
*/
|
||||||
|
public Builder any(List<Object> any) {
|
||||||
|
this.any = any;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StartupSection build() {
|
||||||
|
return new StartupSection(info, required, item, any);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromStartupSection(StartupSection in) {
|
||||||
|
return Builder.class.cast(super.fromSectionType(in)).item(item).any(any);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(name = "Item")
|
@XmlElement(name = "Item")
|
||||||
protected List<StartupSectionItem> item;
|
private List<StartupSectionItem> item;
|
||||||
@XmlAnyElement(lax = true)
|
@XmlAnyElement(lax = true)
|
||||||
protected List<Object> any;
|
private List<Object> any;
|
||||||
|
|
||||||
|
protected StartupSection() {
|
||||||
|
// For JAXB
|
||||||
|
}
|
||||||
|
|
||||||
|
public StartupSection(@Nullable String info, @Nullable Boolean required, List<StartupSectionItem> item, List<Object> any) {
|
||||||
|
super(info, required);
|
||||||
|
this.item = (item != null) ? ImmutableList.<StartupSectionItem>copyOf(item) : Collections.<StartupSectionItem>emptyList();
|
||||||
|
this.any = (any != null) ? ImmutableList.<Object>copyOf(any) : Collections.<Object>emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the item property.
|
* Gets the value of the item property.
|
||||||
|
@ -82,4 +132,25 @@ public class StartupSection extends SectionType<StartupSection> {
|
||||||
}
|
}
|
||||||
return this.any;
|
return this.any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
StartupSection that = StartupSection.class.cast(o);
|
||||||
|
return super.equals(that) &&
|
||||||
|
equal(this.item, that.item) && equal(this.any, that.any);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(super.hashCode(), item, any);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ToStringHelper string() {
|
||||||
|
return super.string().add("item", item).add("any", any);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +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 javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
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 com.google.common.base.Objects;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -57,12 +61,56 @@ import javax.xml.bind.annotation.XmlType;
|
||||||
})
|
})
|
||||||
public class VmQuestionAnswer {
|
public class VmQuestionAnswer {
|
||||||
|
|
||||||
// TODO builder
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return builder().fromVmQuestionAnswer(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private int choiceId;
|
||||||
|
private String questionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VmQuestionAnswer#getChoiceId()
|
||||||
|
*/
|
||||||
|
public Builder choiceId(int choiceId) {
|
||||||
|
this.choiceId = choiceId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VmQuestionAnswer#getQuestionId()
|
||||||
|
*/
|
||||||
|
public Builder questionId(String questionId) {
|
||||||
|
this.questionId = questionId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VmQuestionAnswer build() {
|
||||||
|
return new VmQuestionAnswer(choiceId, questionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromVmQuestionAnswer(VmQuestionAnswer in) {
|
||||||
|
return choiceId(in.getChoiceId()).questionId(in.getQuestionId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@XmlElement(name = "ChoiceId")
|
@XmlElement(name = "ChoiceId")
|
||||||
protected int choiceId;
|
private int choiceId;
|
||||||
@XmlElement(name = "QuestionId", required = true)
|
@XmlElement(name = "QuestionId", required = true)
|
||||||
protected String questionId;
|
private String questionId;
|
||||||
|
|
||||||
|
protected VmQuestionAnswer() {
|
||||||
|
// For JAXB
|
||||||
|
}
|
||||||
|
|
||||||
|
public VmQuestionAnswer(int choiceId, String questionId) {
|
||||||
|
this.choiceId = choiceId;
|
||||||
|
this.questionId = questionId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the choiceId property.
|
* Gets the value of the choiceId property.
|
||||||
|
@ -72,14 +120,6 @@ public class VmQuestionAnswer {
|
||||||
return choiceId;
|
return choiceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of the choiceId property.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void setChoiceId(int value) {
|
|
||||||
this.choiceId = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the questionId property.
|
* Gets the value of the questionId property.
|
||||||
*
|
*
|
||||||
|
@ -92,16 +132,23 @@ public class VmQuestionAnswer {
|
||||||
return questionId;
|
return questionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Sets the value of the questionId property.
|
public boolean equals(Object o) {
|
||||||
*
|
if (this == o)
|
||||||
* @param value
|
return true;
|
||||||
* allowed object is
|
if (o == null || getClass() != o.getClass())
|
||||||
* {@link String }
|
return false;
|
||||||
*
|
VmQuestionAnswer that = VmQuestionAnswer.class.cast(o);
|
||||||
*/
|
return equal(this.choiceId, that.choiceId) && equal(this.questionId, that.questionId);
|
||||||
public void setQuestionId(String value) {
|
|
||||||
this.questionId = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(choiceId, questionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return Objects.toStringHelper("").add("choiceId", choiceId).add("questionId", questionId).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +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 javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
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 com.google.common.base.Objects;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -56,10 +60,56 @@ import javax.xml.bind.annotation.XmlType;
|
||||||
})
|
})
|
||||||
public class VmQuestionAnswerChoice {
|
public class VmQuestionAnswerChoice {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return builder().fromVmQuestionAnswerChoice(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private int id;
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VmQuestionAnswer#getChoiceId()
|
||||||
|
*/
|
||||||
|
public Builder id(int id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VmQuestionAnswer#getQuestionId()
|
||||||
|
*/
|
||||||
|
public Builder text(String text) {
|
||||||
|
this.text = text;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VmQuestionAnswerChoice build() {
|
||||||
|
return new VmQuestionAnswerChoice(id, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromVmQuestionAnswerChoice(VmQuestionAnswerChoice in) {
|
||||||
|
return id(in.getId()).text(in.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected VmQuestionAnswerChoice() {
|
||||||
|
// For JAXB
|
||||||
|
}
|
||||||
|
|
||||||
|
public VmQuestionAnswerChoice(int id, String text) {
|
||||||
|
this.id = id;
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
@XmlElement(name = "Id")
|
@XmlElement(name = "Id")
|
||||||
protected int id;
|
private int id;
|
||||||
@XmlElement(name = "Text")
|
@XmlElement(name = "Text")
|
||||||
protected String text;
|
private String text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the id property.
|
* Gets the value of the id property.
|
||||||
|
@ -69,14 +119,6 @@ public class VmQuestionAnswerChoice {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of the id property.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void setId(int value) {
|
|
||||||
this.id = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the text property.
|
* Gets the value of the text property.
|
||||||
*
|
*
|
||||||
|
@ -89,16 +131,24 @@ public class VmQuestionAnswerChoice {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of the text property.
|
@Override
|
||||||
*
|
public boolean equals(Object o) {
|
||||||
* @param value
|
if (this == o)
|
||||||
* allowed object is
|
return true;
|
||||||
* {@link String }
|
if (o == null || getClass() != o.getClass())
|
||||||
*
|
return false;
|
||||||
*/
|
VmQuestionAnswerChoice that = VmQuestionAnswerChoice.class.cast(o);
|
||||||
public void setText(String value) {
|
return equal(this.id, that.id) && equal(this.text, that.text);
|
||||||
this.text = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(id, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return Objects.toStringHelper("").add("id", id).add("text", text).toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue