Issue 158: Finish Builder for VirtualGuest

This commit is contained in:
Jason King 2011-09-23 10:01:29 +01:00
parent 6fd4aff777
commit d9b4f2746f
1 changed files with 142 additions and 8 deletions

View File

@ -43,12 +43,45 @@ public class VirtualGuest implements Comparable<VirtualGuest> {
} }
public static class Builder { public static class Builder {
private String domain; private long id = -1;
private long accountId = -1;
private Date createDate;
private boolean dedicatedAccountHostOnly;
private String hostname; private String hostname;
private String domain;
private String fullyQualifiedDomainName;
private Date lastVerifiedDate;
private int maxCpu = -1;
private String maxCpuUnits;
private int maxMemory = -1;
private Date metricPollDate;
private Date modifyDate;
private String notes;
private boolean privateNetworkOnly;
private int startCpus = -1;
private int statusId = -1;
private String uuid;
private String primaryBackendIpAddress;
private String primaryIpAddress;
private BillingItemVirtualGuest billingItem;
public Builder id(long id) {
this.id = id;
return this;
}
public Builder domain(String domain) { public Builder accountId(long accountId) {
this.domain = domain; this.accountId = accountId;
return this;
}
public Builder createDate(Date createDate) {
this.createDate = createDate;
return this;
}
public Builder dedicatedAccountHostOnly(boolean dedicatedAccountHostOnly) {
this.dedicatedAccountHostOnly = dedicatedAccountHostOnly;
return this; return this;
} }
@ -57,16 +90,117 @@ public class VirtualGuest implements Comparable<VirtualGuest> {
return this; return this;
} }
public Builder domain(String domain) {
this.domain = domain;
return this;
}
public Builder fullyQualifiedDomainName(String fullyQualifiedDomainName) {
this.fullyQualifiedDomainName = fullyQualifiedDomainName;
return this;
}
public Builder lastVerifiedDate(Date lastVerifiedDate) {
this.lastVerifiedDate = lastVerifiedDate;
return this;
}
public Builder maxCpu(int maxCpu) {
this.maxCpu = maxCpu;
return this;
}
public Builder maxCpuUnits(String maxCpuUnits) {
this.maxCpuUnits = maxCpuUnits;
return this;
}
public Builder maxMemory(int maxMemory) {
this.maxMemory = maxMemory;
return this;
}
public Builder metricPollDate(Date metricPollDate) {
this.metricPollDate = metricPollDate;
return this;
}
public Builder modifyDate(Date modifyDate) {
this.modifyDate = modifyDate;
return this;
}
public Builder notes(String notes) {
this.notes = notes;
return this;
}
public Builder privateNetworkOnly(boolean privateNetworkOnly) {
this.privateNetworkOnly = privateNetworkOnly;
return this;
}
public Builder startCpus(int startCpus) {
this.startCpus = startCpus;
return this;
}
public Builder statusId(int statusId) {
this.statusId = statusId;
return this;
}
public Builder uuid(String uuid) {
this.uuid = uuid;
return this;
}
public Builder primaryBackendIpAddress(String primaryBackendIpAddress) {
this.primaryBackendIpAddress = primaryBackendIpAddress;
return this;
}
public Builder primaryIpAddress(String primaryIpAddress) {
this.primaryIpAddress = primaryIpAddress;
return this;
}
public Builder billingItem(BillingItemVirtualGuest billingItem) {
this.billingItem = billingItem;
return this;
}
public VirtualGuest build() { public VirtualGuest build() {
return new VirtualGuest(-1, null, true, domain,null,hostname, return new VirtualGuest(accountId, createDate, dedicatedAccountHostOnly, domain,
-1,null,-1, null,-1,null,null,null, fullyQualifiedDomainName, hostname, id, lastVerifiedDate, maxCpu,
true,-1,-1,null,null,null,null); maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes,
privateNetworkOnly, startCpus, statusId, uuid, primaryBackendIpAddress,
primaryIpAddress,billingItem);
} }
public static Builder fromVirtualGuest(VirtualGuest in) { public static Builder fromVirtualGuest(VirtualGuest in) {
return VirtualGuest.builder() return VirtualGuest.builder()
.accountId(in.getAccountId())
.createDate(in.getCreateDate())
.dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly())
.domain(in.getDomain()) .domain(in.getDomain())
.hostname(in.getHostname()); .fullyQualifiedDomainName(in.getFullyQualifiedDomainName())
.hostname(in.getHostname())
.id(in.getId())
.lastVerifiedDate(in.getLastVerifiedDate())
.maxCpu(in.getMaxCpu())
.maxCpuUnits(in.getMaxCpuUnits())
.maxMemory(in.getMaxMemory())
.metricPollDate(in.getMetricPollDate())
.modifyDate(in.getModifyDate())
.notes(in.getNotes())
.privateNetworkOnly(in.isPrivateNetworkOnly())
.startCpus(in.getStartCpus())
.statusId(in.getStatusId())
.uuid(in.getUuid())
.primaryBackendIpAddress(in.getPrimaryBackendIpAddress())
.primaryIpAddress(in.getPrimaryIpAddress())
.billingItem(in.getBillingItem());
} }
} }
@ -430,7 +564,7 @@ public class VirtualGuest implements Comparable<VirtualGuest> {
+ ", metricPollDate=" + metricPollDate + ", modifyDate=" + modifyDate + ", notes=" + notes + ", metricPollDate=" + metricPollDate + ", modifyDate=" + modifyDate + ", notes=" + notes
+ ", primaryBackendIpAddress=" + primaryBackendIpAddress + ", primaryIpAddress=" + primaryIpAddress + ", primaryBackendIpAddress=" + primaryBackendIpAddress + ", primaryIpAddress=" + primaryIpAddress
+ ", privateNetworkOnly=" + privateNetworkOnly + ", startCpus=" + startCpus + ", statusId=" + statusId + ", privateNetworkOnly=" + privateNetworkOnly + ", startCpus=" + startCpus + ", statusId=" + statusId
+ ", uuid=" + uuid + "]"; + ", uuid=" + uuid + ", billingItem="+billingItem+"]";
} }
} }