mirror of https://github.com/apache/jclouds.git
softlayer: issue 971 adjusting builders and applying ConstructorProperties to domain objects
This commit is contained in:
parent
ed8a1d640f
commit
ec74987054
|
@ -56,7 +56,7 @@ public class ProductItems {
|
|||
|
||||
/**
|
||||
* Creates a function to get the ProductItemPrice for the ProductItem. Currently returns the
|
||||
* first price. This will need to be changed if more than one price is returned.
|
||||
* first prices. This will need to be changed if more than one prices is returned.
|
||||
*/
|
||||
public static Function<ProductItem, ProductItemPrice> price() {
|
||||
return new Function<ProductItem, ProductItemPrice>() {
|
||||
|
@ -71,7 +71,7 @@ public class ProductItems {
|
|||
|
||||
/**
|
||||
* Creates a function to get the ProductItem for the ProductItemPrice. Copies the category
|
||||
* information from the price to the item if necessary The ProductItemPrices must have
|
||||
* information from the prices to the item if necessary The ProductItemPrices must have
|
||||
* ProductItems.
|
||||
*/
|
||||
public static Function<ProductItemPrice, ProductItem> item() {
|
||||
|
@ -80,7 +80,7 @@ public class ProductItems {
|
|||
public ProductItem apply(ProductItemPrice productItemPrice) {
|
||||
Set<ProductItemCategory> categories = productItemPrice.getCategories();
|
||||
ProductItem item = productItemPrice.getItem();
|
||||
ProductItem.Builder builder = ProductItem.Builder.fromProductItem(productItemPrice.getItem());
|
||||
ProductItem.Builder builder = productItemPrice.getItem().toBuilder();
|
||||
if (item.getCategories().size() == 0 && categories.size() != 0) {
|
||||
builder.categories(categories);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ import com.google.common.collect.Iterables;
|
|||
|
||||
/**
|
||||
* Converts a set of ProductItems to Hardware. All cores have a speed of 2.0Ghz The Hardware Id will
|
||||
* be a comma separated list containing the price ids: cpus,ram,volume
|
||||
* be a comma separated list containing the prices ids: cpus,ram,volume
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
|
|
|
@ -126,7 +126,7 @@ public class SoftLayerComputeServiceAdapter implements
|
|||
|
||||
ProductOrder order = ProductOrder.builder().packageId(productPackageSupplier.get().getId())
|
||||
.location(template.getLocation().getId()).quantity(1).useHourlyPricing(true).prices(getPrices(template))
|
||||
.virtualGuest(newGuest).build();
|
||||
.virtualGuests(newGuest).build();
|
||||
|
||||
logger.debug(">> ordering new virtualGuest domain(%s) hostname(%s)", domainName, name);
|
||||
ProductOrderReceipt productOrderReceipt = client.getVirtualGuestClient().orderVirtualGuest(order);
|
||||
|
|
|
@ -18,28 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.softlayer.config;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
||||
import org.jclouds.softlayer.domain.Datacenter;
|
||||
import org.jclouds.softlayer.domain.OperatingSystem;
|
||||
import org.jclouds.softlayer.domain.PowerState;
|
||||
import org.jclouds.softlayer.domain.VirtualGuest;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -47,72 +29,6 @@ import com.google.inject.Provides;
|
|||
*/
|
||||
public class SoftLayerParserModule extends AbstractModule {
|
||||
|
||||
@Singleton
|
||||
public static class VirtualGuestAdapter implements JsonSerializer<VirtualGuest>, JsonDeserializer<VirtualGuest> {
|
||||
|
||||
public JsonElement serialize(VirtualGuest src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return context.serialize(src);
|
||||
}
|
||||
|
||||
public VirtualGuest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
return apply(context.<VirtualGuestInternal> deserialize(json, VirtualGuestInternal.class));
|
||||
}
|
||||
|
||||
public VirtualGuest apply(VirtualGuestInternal in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal class that flattens billingItem into billingItemId
|
||||
*/
|
||||
public static class VirtualGuestInternal extends VirtualGuest {
|
||||
private BillingItem billingItem;
|
||||
|
||||
public VirtualGuestInternal(int accountId, Date createDate, boolean dedicatedAccountHostOnly, String domain,
|
||||
String fullyQualifiedDomainName, String hostname, int id, Date lastVerifiedDate, int maxCpu,
|
||||
String maxCpuUnits, int maxMemory, Date metricPollDate, Date modifyDate, String notes,
|
||||
boolean privateNetworkOnly, int startCpus, int statusId, String uuid, String primaryBackendIpAddress,
|
||||
String primaryIpAddress, int billingItemId, OperatingSystem operatingSystem, Datacenter datacenter,
|
||||
PowerState powerState) {
|
||||
super(accountId, createDate, dedicatedAccountHostOnly, domain, fullyQualifiedDomainName, hostname, id,
|
||||
lastVerifiedDate, maxCpu, maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes,
|
||||
privateNetworkOnly, startCpus, statusId, uuid, primaryBackendIpAddress, primaryIpAddress,
|
||||
billingItemId, operatingSystem, datacenter, powerState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBillingItemId() {
|
||||
return billingItem != null ? billingItem.id : -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BillingItem {
|
||||
|
||||
private int id = -1;
|
||||
|
||||
// for deserializer
|
||||
BillingItem() {
|
||||
|
||||
}
|
||||
|
||||
public BillingItem(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public Map<Type, Object> provideCustomAdapterBindings() {
|
||||
return ImmutableMap.<Type, Object> of(VirtualGuest.class, new VirtualGuestAdapter());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -21,135 +21,156 @@ package org.jclouds.softlayer.domain;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Strings.emptyToNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class Address
|
||||
*
|
||||
* @author Jason King
|
||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Account_Address"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class Address implements Comparable<Address> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public class Address {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int id = -1;
|
||||
private String country;
|
||||
private String state;
|
||||
private String description;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromAddress(this);
|
||||
}
|
||||
|
||||
public Builder id(int id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int id;
|
||||
protected String country;
|
||||
protected String state;
|
||||
protected String description;
|
||||
|
||||
/**
|
||||
* @see Address#getId()
|
||||
*/
|
||||
public T id(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder country(String country) {
|
||||
/**
|
||||
* @see Address#getCountry()
|
||||
*/
|
||||
public T country(String country) {
|
||||
this.country = country;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder state(String state) {
|
||||
/**
|
||||
* @see Address#getState()
|
||||
*/
|
||||
public T state(String state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see Address#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Address build() {
|
||||
return new Address(id, country, state, description);
|
||||
}
|
||||
|
||||
public static Builder fromAddress(Address in) {
|
||||
return Address.builder().id(in.getId())
|
||||
.country(in.getCountry())
|
||||
.state(in.getState())
|
||||
.description(in.getDescription());
|
||||
public T fromAddress(Address in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.country(in.getCountry())
|
||||
.state(in.getState())
|
||||
.description(in.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
private int id = -1;
|
||||
private String country;
|
||||
private String state;
|
||||
private String description;
|
||||
|
||||
// for deserializer
|
||||
Address() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Address(int id, String country, String state, String description) {
|
||||
private final int id;
|
||||
private final String country;
|
||||
private final String state;
|
||||
private final String description;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "country", "state", "description"
|
||||
})
|
||||
protected Address(int id, String country, @Nullable String state, @Nullable String description) {
|
||||
this.id = id;
|
||||
this.country = checkNotNull(emptyToNull(country),"country cannot be null or empty:"+country);
|
||||
this.state = state;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Address arg0) {
|
||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The unique id of the address.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The country of the address.
|
||||
*/
|
||||
public String getCountry() {
|
||||
return country;
|
||||
return this.country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The state of the address.
|
||||
*/
|
||||
@Nullable
|
||||
public String getState() {
|
||||
return state;
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The description of the address.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromAddress(this);
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id ^ (id >>> 32));
|
||||
return result;
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Address other = (Address) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Address that = Address.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("country", country).add("state", state).add("description", description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", country=" + country + ", state=" + state + ", description=" + description + "]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,161 +20,186 @@ package org.jclouds.softlayer.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class Datacenter
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Location_Datacenter"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class Datacenter implements Comparable<Datacenter> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public class Datacenter {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int id = -1;
|
||||
private String name;
|
||||
private String longName;
|
||||
private Address locationAddress;
|
||||
private Set<Region> regions = Sets.newLinkedHashSet();
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromDatacenter(this);
|
||||
}
|
||||
|
||||
public Builder id(int id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int id;
|
||||
protected String name;
|
||||
protected String longName;
|
||||
protected Address locationAddress;
|
||||
protected Set<Region> regions = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see Datacenter#getId()
|
||||
*/
|
||||
public T id(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see Datacenter#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder longName(String longName) {
|
||||
/**
|
||||
* @see Datacenter#getLongName()
|
||||
*/
|
||||
public T longName(String longName) {
|
||||
this.longName = longName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder locationAddress(Address locationAddress) {
|
||||
/**
|
||||
* @see Datacenter#getLocationAddress()
|
||||
*/
|
||||
public T locationAddress(Address locationAddress) {
|
||||
this.locationAddress = locationAddress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder region(Region regions) {
|
||||
this.regions.add(checkNotNull(regions, "regions"));
|
||||
return this;
|
||||
/**
|
||||
* @see Datacenter#getRegions()
|
||||
*/
|
||||
public T regions(Set<Region> regions) {
|
||||
this.regions = ImmutableSet.copyOf(checkNotNull(regions, "regions"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder regions(Iterable<Region> regions) {
|
||||
this.regions = ImmutableSet.<Region> copyOf(checkNotNull(regions, "regions"));
|
||||
return this;
|
||||
public T regions(Region... in) {
|
||||
return regions(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Datacenter build() {
|
||||
return new Datacenter(id, name, longName, locationAddress, regions);
|
||||
}
|
||||
|
||||
public static Builder fromDatacenter(Datacenter in) {
|
||||
return Datacenter.builder().id(in.getId()).name(in.getName())
|
||||
.longName(in.getLongName()).locationAddress(in.getLocationAddress())
|
||||
public T fromDatacenter(Datacenter in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.longName(in.getLongName())
|
||||
.locationAddress(in.getLocationAddress())
|
||||
.regions(in.getRegions());
|
||||
}
|
||||
}
|
||||
|
||||
private int id = -1;
|
||||
private String name;
|
||||
private String longName;
|
||||
private Address locationAddress;
|
||||
private Set<Region> regions = Sets.newLinkedHashSet();
|
||||
// for deserializer
|
||||
Datacenter() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Datacenter(int id, String name, String longName, Address locationAddress, Iterable<Region> regions) {
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final String longName;
|
||||
private final Address locationAddress;
|
||||
private final Set<Region> regions;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "name", "longName", "locationAddress", "regions"
|
||||
})
|
||||
protected Datacenter(int id, @Nullable String name, @Nullable String longName, @Nullable Address locationAddress, @Nullable Set<Region> regions) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.longName = longName;
|
||||
this.locationAddress = locationAddress;
|
||||
this.regions = ImmutableSet.<Region> copyOf(checkNotNull(regions, "regions"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Datacenter arg0) {
|
||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
||||
this.regions = regions == null ? ImmutableSet.<Region>of() : ImmutableSet.copyOf(regions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The unique identifier of a specific location.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A short location description.
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A longer location description.
|
||||
*/
|
||||
@Nullable
|
||||
public String getLongName() {
|
||||
return longName;
|
||||
return this.longName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A location's physical address (optional).
|
||||
*/
|
||||
@Nullable
|
||||
public Address getLocationAddress() {
|
||||
return locationAddress;
|
||||
return this.locationAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* A location can be a member of 1 or more regions.
|
||||
* Sometimes the list of regions is empty, for example as a new Datacenter is being added.
|
||||
* The list of regions usually contains one with keyName=FIRST_AVAILABLE which should be ignored.
|
||||
*
|
||||
* @return The regions to which a location belongs.
|
||||
*/
|
||||
public Set<Region> getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromDatacenter(this);
|
||||
return this.regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id ^ (id >>> 32));
|
||||
return result;
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Datacenter other = (Datacenter) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Datacenter that = Datacenter.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("longName", longName).add("locationAddress", locationAddress).add("regions", regions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", country=" + name + ", state=" + longName + "], locationAddress=" + locationAddress + ", regions="+regions+"]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,118 +20,123 @@ package org.jclouds.softlayer.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Extends the SoftLayer_Software_Component data type to include operating system specific properties.
|
||||
*
|
||||
*
|
||||
* @author Jason King
|
||||
* @see <a href=
|
||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Software_Component_OperatingSystem"
|
||||
* />
|
||||
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Software_Component_OperatingSystem"
|
||||
/>
|
||||
*/
|
||||
public class OperatingSystem implements Comparable<OperatingSystem> {
|
||||
public class OperatingSystem {
|
||||
|
||||
// There are other properties
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int id = -1;
|
||||
private Set<Password> passwords = Sets.newLinkedHashSet();
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromOperatingSystem(this);
|
||||
}
|
||||
|
||||
public Builder id(int id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int id;
|
||||
protected Set<Password> passwords = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see OperatingSystem#getId()
|
||||
*/
|
||||
public T id(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder password(Password password) {
|
||||
this.passwords.add(checkNotNull(password, "password"));
|
||||
return this;
|
||||
/**
|
||||
* @see OperatingSystem#getPasswords()
|
||||
*/
|
||||
public T passwords(Set<Password> passwords) {
|
||||
this.passwords = ImmutableSet.copyOf(checkNotNull(passwords, "passwords"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder passwords(Iterable<Password> passwords) {
|
||||
this.passwords = ImmutableSet.<Password> copyOf(checkNotNull(passwords, "passwords"));
|
||||
return this;
|
||||
public T passwords(Password... in) {
|
||||
return passwords(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public OperatingSystem build() {
|
||||
return new OperatingSystem(id, passwords);
|
||||
}
|
||||
|
||||
public static Builder fromOperatingSystem(OperatingSystem in) {
|
||||
return OperatingSystem.builder()
|
||||
.id(in.getId())
|
||||
.passwords(in.getPasswords());
|
||||
public T fromOperatingSystem(OperatingSystem in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.passwords(in.getPasswords());
|
||||
}
|
||||
}
|
||||
|
||||
private int id = -1;
|
||||
private Set<Password> passwords = Sets.newLinkedHashSet();
|
||||
|
||||
// for deserializer
|
||||
OperatingSystem() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public OperatingSystem(int id,Iterable<Password> passwords) {
|
||||
private final int id;
|
||||
private final Set<Password> passwords;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "passwords"
|
||||
})
|
||||
protected OperatingSystem(int id, @Nullable Set<Password> passwords) {
|
||||
this.id = id;
|
||||
this.passwords = ImmutableSet.<Password> copyOf(checkNotNull(passwords, "passwords"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(OperatingSystem arg0) {
|
||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
||||
this.passwords = passwords == null ? ImmutableSet.<Password>of() : ImmutableSet.copyOf(passwords);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An ID number identifying this Software Component (Software Installation)
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Username/Password pairs used for access to this Software Installation.
|
||||
*/
|
||||
public Set<Password> getPasswords() {
|
||||
return passwords;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromOperatingSystem(this);
|
||||
return this.passwords;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id ^ (id >>> 32));
|
||||
return result;
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
OperatingSystem other = (OperatingSystem) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
OperatingSystem that = OperatingSystem.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("passwords", passwords);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", passwords=" + passwords + "]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -21,121 +21,134 @@ package org.jclouds.softlayer.domain;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Strings.emptyToNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* Contains a password for a specific software component instance
|
||||
*
|
||||
* @author Jason King
|
||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Software_Component_Password"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class Password implements Comparable<Password> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public class Password {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int id = -1;
|
||||
private String username;
|
||||
private String password;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromPassword(this);
|
||||
}
|
||||
|
||||
public Builder id(int id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int id;
|
||||
protected String username;
|
||||
protected String password;
|
||||
|
||||
/**
|
||||
* @see Password#getId()
|
||||
*/
|
||||
public T id(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder username(String username) {
|
||||
/**
|
||||
* @see Password#getUsername()
|
||||
*/
|
||||
public T username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder password(String password) {
|
||||
/**
|
||||
* @see Password#getPassword()
|
||||
*/
|
||||
public T password(String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Password build() {
|
||||
return new Password(id, username, password);
|
||||
}
|
||||
|
||||
public static Builder fromPassword(Password in) {
|
||||
return Password.builder().id(in.getId())
|
||||
.username(in.getUsername())
|
||||
.password(in.getPassword());
|
||||
public T fromPassword(Password in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.username(in.getUsername())
|
||||
.password(in.getPassword());
|
||||
}
|
||||
}
|
||||
|
||||
private int id = -1;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
// for deserializer
|
||||
Password() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Password(int id, String username, String password) {
|
||||
private final int id;
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
@ConstructorProperties({"id", "username", "password"})
|
||||
public Password(int id, String username, @Nullable String password) {
|
||||
this.id = id;
|
||||
this.username = checkNotNull(emptyToNull(username),"username cannot be null or empty:"+username);
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Password arg0) {
|
||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An id number for this specific username/password pair.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The username part of the username/password pair.
|
||||
*/
|
||||
@Nullable
|
||||
public String getUsername() {
|
||||
return username;
|
||||
return this.username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The password part of the username/password pair.
|
||||
*/
|
||||
@Nullable
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromPassword(this);
|
||||
return this.password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id ^ (id >>> 32));
|
||||
return result;
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Password other = (Password) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Password that = Password.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("username", username).add("password", password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Password [id=" + id + ", username=" + username + ", password=**********]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,83 +20,98 @@ package org.jclouds.softlayer.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* The power state class provides a common set of values for which a guest's power state will be presented in the SoftLayer API.
|
||||
* The power state class provides a common set of values for which a guest's power state will be presented in the SoftLayer API.
|
||||
*
|
||||
* @author Jason King
|
||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Power_State"
|
||||
* />
|
||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Power_State"
|
||||
/>
|
||||
*/
|
||||
public class PowerState implements Comparable<PowerState> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public class PowerState {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private VirtualGuest.State keyName;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromPowerState(this);
|
||||
}
|
||||
|
||||
public Builder keyName(VirtualGuest.State keyName) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected VirtualGuest.State keyName;
|
||||
|
||||
/**
|
||||
* @see PowerState#getKeyName()
|
||||
*/
|
||||
public T keyName(VirtualGuest.State keyName) {
|
||||
this.keyName = keyName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public PowerState build() {
|
||||
return new PowerState(keyName);
|
||||
}
|
||||
|
||||
public static Builder fromAddress(PowerState in) {
|
||||
return PowerState.builder().keyName(in.getKeyName());
|
||||
public T fromPowerState(PowerState in) {
|
||||
return this
|
||||
.keyName(in.getKeyName());
|
||||
}
|
||||
}
|
||||
|
||||
private VirtualGuest.State keyName;
|
||||
|
||||
// for deserializer
|
||||
PowerState() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final VirtualGuest.State keyName;
|
||||
|
||||
@ConstructorProperties("keyName")
|
||||
public PowerState(VirtualGuest.State keyName) {
|
||||
this.keyName = checkNotNull(keyName,"keyName cannot be null or empty:"+keyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PowerState arg0) {
|
||||
return keyName.compareTo(arg0.keyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps onto {@code VirtualGuest.State}
|
||||
* @return The key name of a power state.
|
||||
*
|
||||
* @return The key name of a power state.
|
||||
*/
|
||||
@Nullable
|
||||
public VirtualGuest.State getKeyName() {
|
||||
return keyName;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromAddress(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PowerState that = (PowerState) o;
|
||||
if (keyName != null ? !keyName.equals(that.keyName) : that.keyName != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return this.keyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return keyName != null ? keyName.hashCode() : 0;
|
||||
return Objects.hashCode(keyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
PowerState that = PowerState.class.cast(obj);
|
||||
return Objects.equal(this.keyName, that.keyName);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("keyName", keyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[keyName=" + keyName + "]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,131 +20,154 @@ package org.jclouds.softlayer.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* The SoftLayer_Product_Item data type contains general information relating to
|
||||
* a single SoftLayer product.
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href=
|
||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item"
|
||||
* />
|
||||
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item"
|
||||
/>
|
||||
*/
|
||||
public class ProductItem implements Comparable<ProductItem> {
|
||||
public class ProductItem {
|
||||
|
||||
// TODO there are more elements than this.
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int id = -1;
|
||||
private String description;
|
||||
private String units;
|
||||
private Float capacity;
|
||||
private Set<ProductItemPrice> prices = Sets.newLinkedHashSet();
|
||||
private Set<ProductItemCategory> categories = Sets.newLinkedHashSet();
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromProductItem(this);
|
||||
}
|
||||
|
||||
public Builder id(int id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int id;
|
||||
protected String description;
|
||||
protected String units;
|
||||
protected Float capacity;
|
||||
protected Set<ProductItemPrice> prices = ImmutableSet.of();
|
||||
protected Set<ProductItemCategory> categories = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see ProductItem#getId()
|
||||
*/
|
||||
public T id(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see ProductItem#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder units(String units) {
|
||||
/**
|
||||
* @see ProductItem#getUnits()
|
||||
*/
|
||||
public T units(String units) {
|
||||
this.units = units;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder capacity(Float capacity) {
|
||||
/**
|
||||
* @see ProductItem#getCapacity()
|
||||
*/
|
||||
public T capacity(Float capacity) {
|
||||
this.capacity = capacity;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder price(ProductItemPrice prices) {
|
||||
this.prices.add(checkNotNull(prices, "prices"));
|
||||
return this;
|
||||
/**
|
||||
* @see ProductItem#getPrices()
|
||||
*/
|
||||
public T prices(Set<ProductItemPrice> prices) {
|
||||
this.prices = ImmutableSet.copyOf(checkNotNull(prices, "prices"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder prices(Iterable<ProductItemPrice> prices) {
|
||||
this.prices = ImmutableSet.<ProductItemPrice> copyOf(checkNotNull(prices, "prices"));
|
||||
return this;
|
||||
public T prices(ProductItemPrice... in) {
|
||||
return prices(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductItem#getCategories()
|
||||
*/
|
||||
public T categories(Set<ProductItemCategory> categories) {
|
||||
this.categories = ImmutableSet.copyOf(checkNotNull(categories, "categories"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder category(ProductItemCategory categories) {
|
||||
this.categories.add(checkNotNull(categories, "categories"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder categories(Iterable<ProductItemCategory> categories) {
|
||||
this.categories = ImmutableSet.<ProductItemCategory> copyOf(checkNotNull(categories, "categories"));
|
||||
return this;
|
||||
public T categories(ProductItemCategory... in) {
|
||||
return categories(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public ProductItem build() {
|
||||
return new ProductItem(id, description, units, capacity, prices, categories);
|
||||
}
|
||||
|
||||
public static Builder fromProductItem(ProductItem in) {
|
||||
return ProductItem.builder().id(in.getId())
|
||||
.description(in.getDescription())
|
||||
.units(in.getUnits())
|
||||
.capacity(in.getCapacity())
|
||||
.prices(in.getPrices())
|
||||
.categories(in.getCategories());
|
||||
public T fromProductItem(ProductItem in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.description(in.getDescription())
|
||||
.units(in.getUnits())
|
||||
.capacity(in.getCapacity())
|
||||
.prices(in.getPrices())
|
||||
.categories(in.getCategories());
|
||||
}
|
||||
}
|
||||
|
||||
private int id = -1;
|
||||
private String description;
|
||||
private String units;
|
||||
private Float capacity;
|
||||
private Set<ProductItemPrice> prices = Sets.newLinkedHashSet();
|
||||
private Set<ProductItemCategory> categories = Sets.newLinkedHashSet();
|
||||
|
||||
// for deserializer
|
||||
ProductItem() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public ProductItem(int id, String description, String units, Float capacity,
|
||||
Iterable<ProductItemPrice> prices, Iterable<ProductItemCategory> categories) {
|
||||
private final int id;
|
||||
private final String description;
|
||||
private final String units;
|
||||
private final Float capacity;
|
||||
private final Set<ProductItemPrice> prices;
|
||||
private final Set<ProductItemCategory> categories;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "description", "units", "capacity", "prices", "categories"
|
||||
})
|
||||
protected ProductItem(int id, @Nullable String description, @Nullable String units, @Nullable Float capacity, @Nullable Set<ProductItemPrice> prices, @Nullable Set<ProductItemCategory> categories) {
|
||||
this.id = id;
|
||||
this.description = description;
|
||||
this.units = units;
|
||||
this.capacity = capacity;
|
||||
this.prices = ImmutableSet.<ProductItemPrice> copyOf(checkNotNull(prices, "prices"));
|
||||
this.categories = ImmutableSet.<ProductItemCategory> copyOf(checkNotNull(categories, "categories"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ProductItem arg0) {
|
||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
||||
this.prices = prices == null ? ImmutableSet.<ProductItemPrice>of() : ImmutableSet.copyOf(prices);
|
||||
this.categories = categories == null ? ImmutableSet.<ProductItemCategory>of() : ImmutableSet.copyOf(categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The unique identifier of a specific location.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A product's description
|
||||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -152,64 +175,54 @@ public class ProductItem implements Comparable<ProductItem> {
|
|||
*/
|
||||
@Nullable
|
||||
public String getUnits() {
|
||||
return units;
|
||||
return this.units;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Some Product Items have capacity information such as RAM and
|
||||
* bandwidth, and others. This provides the numerical representation
|
||||
* of the capacity given in the description of this product item.
|
||||
bandwidth, and others. This provides the numerical representation
|
||||
of the capacity given in the description of this product item.
|
||||
*/
|
||||
@Nullable
|
||||
public Float getCapacity() {
|
||||
return capacity;
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return A product item's prices.
|
||||
*/
|
||||
public Set<ProductItemPrice> getPrices() {
|
||||
return prices;
|
||||
return this.prices;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return An item's associated item categories.
|
||||
*/
|
||||
public Set<ProductItemCategory> getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromProductItem(this);
|
||||
return this.categories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id ^ (id >>> 32));
|
||||
return result;
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ProductItem other = (ProductItem) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ProductItem that = ProductItem.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("description", description).add("units", units).add("capacity", capacity).add("prices", prices).add("categories", categories);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProductItem [id=" + id + ", description=" + description + ", units=" + units + ", capacity=" + capacity
|
||||
+ ", prices=" + prices + ", categories=" + categories + "]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,123 +18,139 @@
|
|||
*/
|
||||
package org.jclouds.softlayer.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* The SoftLayer_Product_Item_Category data type contains
|
||||
* general category information for prices.
|
||||
*
|
||||
*
|
||||
* @author Jason King
|
||||
* @see <a href=
|
||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Category"
|
||||
* />
|
||||
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Category"
|
||||
/>
|
||||
*/
|
||||
public class ProductItemCategory implements Comparable<ProductItemCategory> {
|
||||
public class ProductItemCategory {
|
||||
|
||||
// TODO there are more elements than this.
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int id = -1;
|
||||
private String name;
|
||||
private String categoryCode;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromProductItemCategory(this);
|
||||
}
|
||||
|
||||
public Builder id(int id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int id;
|
||||
protected String name;
|
||||
protected String categoryCode;
|
||||
|
||||
/**
|
||||
* @see ProductItemCategory#getId()
|
||||
*/
|
||||
public T id(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see ProductItemCategory#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder categoryCode(String categoryCode) {
|
||||
/**
|
||||
* @see ProductItemCategory#getCategoryCode()
|
||||
*/
|
||||
public T categoryCode(String categoryCode) {
|
||||
this.categoryCode = categoryCode;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ProductItemCategory build() {
|
||||
return new ProductItemCategory(id, name, categoryCode);
|
||||
}
|
||||
|
||||
public static Builder fromProductItemCategory(ProductItemCategory in) {
|
||||
return ProductItemCategory.builder().id(in.getId())
|
||||
.name(in.getName())
|
||||
.categoryCode(in.getCategoryCode());
|
||||
public T fromProductItemCategory(ProductItemCategory in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.categoryCode(in.getCategoryCode());
|
||||
}
|
||||
}
|
||||
|
||||
private int id = -1;
|
||||
private String name;
|
||||
private String categoryCode;
|
||||
|
||||
// for deserializer
|
||||
ProductItemCategory() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public ProductItemCategory(int id, String name, String categoryCode) {
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final String categoryCode;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "name", "categoryCode"
|
||||
})
|
||||
protected ProductItemCategory(int id, @Nullable String name, @Nullable String categoryCode) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.categoryCode = categoryCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ProductItemCategory arg0) {
|
||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The unique identifier of a specific location.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The friendly, descriptive name of the category as seen on the order forms and on invoices.
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The code used to identify this category.
|
||||
*/
|
||||
@Nullable
|
||||
public String getCategoryCode() {
|
||||
return categoryCode;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromProductItemCategory(this);
|
||||
return this.categoryCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id ^ (id >>> 32));
|
||||
return result;
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ProductItemCategory other = (ProductItemCategory) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ProductItemCategory that = ProductItemCategory.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("categoryCode", categoryCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProductItemCategory [id=" + id + ", name=" + name + ", categoryCode=" + categoryCode + "]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,183 +20,209 @@ package org.jclouds.softlayer.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* The SoftLayer_Product_Item_Price data type contains general information
|
||||
* relating to a single SoftLayer product item price. You can find out what
|
||||
* packages each price is in as well as which category under which this price is
|
||||
* relating to a single SoftLayer product item prices. You can find out what
|
||||
* packages each prices is in as well as which category under which this prices is
|
||||
* sold. All prices are returned in Floating point values measured in US Dollars
|
||||
* ($USD).
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href=
|
||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price"
|
||||
* />
|
||||
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price"
|
||||
/>
|
||||
*/
|
||||
public class ProductItemPrice implements Comparable<ProductItemPrice> {
|
||||
// TODO there are more elements than this.
|
||||
public class ProductItemPrice {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int id = -1;
|
||||
private long itemId = -1;
|
||||
private Float recurringFee;
|
||||
private Float hourlyRecurringFee;
|
||||
private ProductItem item;
|
||||
private Set<ProductItemCategory> categories = Sets.newLinkedHashSet();
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromProductItemPrice(this);
|
||||
}
|
||||
|
||||
public Builder id(int id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int id;
|
||||
protected long itemId;
|
||||
protected Float recurringFee;
|
||||
protected Float hourlyRecurringFee;
|
||||
protected ProductItem item;
|
||||
protected Set<ProductItemCategory> categories = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see ProductItemPrice#getId()
|
||||
*/
|
||||
public T id(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder itemId(long itemId) {
|
||||
/**
|
||||
* @see ProductItemPrice#getItemId()
|
||||
*/
|
||||
public T itemId(long itemId) {
|
||||
this.itemId = itemId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder recurringFee(Float recurringFee) {
|
||||
/**
|
||||
* @see ProductItemPrice#getRecurringFee()
|
||||
*/
|
||||
public T recurringFee(Float recurringFee) {
|
||||
this.recurringFee = recurringFee;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder hourlyRecurringFee(Float hourlyRecurringFee) {
|
||||
/**
|
||||
* @see ProductItemPrice#getHourlyRecurringFee()
|
||||
*/
|
||||
public T hourlyRecurringFee(Float hourlyRecurringFee) {
|
||||
this.hourlyRecurringFee = hourlyRecurringFee;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder item(ProductItem item) {
|
||||
/**
|
||||
* @see ProductItemPrice#getItem()
|
||||
*/
|
||||
public T item(ProductItem item) {
|
||||
this.item = item;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder category(ProductItemCategory categories) {
|
||||
this.categories.add(checkNotNull(categories, "categories"));
|
||||
return this;
|
||||
/**
|
||||
* @see ProductItemPrice#getCategories()
|
||||
*/
|
||||
public T categories(Set<ProductItemCategory> categories) {
|
||||
this.categories = ImmutableSet.copyOf(checkNotNull(categories, "categories"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder categories(Iterable<ProductItemCategory> categories) {
|
||||
this.categories = ImmutableSet.<ProductItemCategory> copyOf(checkNotNull(categories, "categories"));
|
||||
return this;
|
||||
public T categories(ProductItemCategory... in) {
|
||||
return categories(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public ProductItemPrice build() {
|
||||
return new ProductItemPrice(id, itemId, recurringFee, hourlyRecurringFee, item, categories);
|
||||
}
|
||||
|
||||
public static Builder fromPrice(ProductItemPrice in) {
|
||||
return ProductItemPrice.builder().id(in.getId()).itemId(in.getItemId())
|
||||
.hourlyRecurringFee(in.getHourlyRecurringFee()).recurringFee(in.getRecurringFee());
|
||||
public T fromProductItemPrice(ProductItemPrice in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.itemId(in.getItemId())
|
||||
.recurringFee(in.getRecurringFee())
|
||||
.hourlyRecurringFee(in.getHourlyRecurringFee())
|
||||
.item(in.getItem())
|
||||
.categories(in.getCategories());
|
||||
}
|
||||
}
|
||||
|
||||
private int id = -1;
|
||||
private long itemId = -1;
|
||||
private Float recurringFee;
|
||||
private Float hourlyRecurringFee;
|
||||
private ProductItem item;
|
||||
private Set<ProductItemCategory> categories = Sets.newLinkedHashSet();
|
||||
|
||||
// for deserializer
|
||||
ProductItemPrice() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public ProductItemPrice(int id, long itemId, Float recurringFee, Float hourlyRecurringFee, ProductItem item, Iterable<ProductItemCategory> categories) {
|
||||
private final int id;
|
||||
private final long itemId;
|
||||
private final Float recurringFee;
|
||||
private final Float hourlyRecurringFee;
|
||||
private final ProductItem item;
|
||||
private final Set<ProductItemCategory> categories;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "itemId", "recurringFee", "hourlyRecurringFee", "item", "categories"
|
||||
})
|
||||
protected ProductItemPrice(int id, long itemId, @Nullable Float recurringFee, @Nullable Float hourlyRecurringFee, @Nullable ProductItem item, @Nullable Set<ProductItemCategory> categories) {
|
||||
this.id = id;
|
||||
this.itemId = itemId;
|
||||
this.recurringFee = recurringFee;
|
||||
this.hourlyRecurringFee = hourlyRecurringFee;
|
||||
this.item = item;
|
||||
this.categories = ImmutableSet.<ProductItemCategory> copyOf(checkNotNull(categories, "categories"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ProductItemPrice arg0) {
|
||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
||||
this.categories = categories == null ? ImmutableSet.<ProductItemCategory>of() : ImmutableSet.copyOf(categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The unique identifier of a Product Item Price.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The unique identifier for a product Item
|
||||
*/
|
||||
public long getItemId() {
|
||||
return itemId;
|
||||
return this.itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A recurring fee is a fee that happens every billing period. This
|
||||
* fee is represented as a Floating point decimal in US dollars
|
||||
* ($USD).
|
||||
fee is represented as a Floating point decimal in US dollars
|
||||
($USD).
|
||||
*/
|
||||
@Nullable
|
||||
public Float getRecurringFee() {
|
||||
return recurringFee;
|
||||
return this.recurringFee;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The hourly price for this item, should this item be part of an
|
||||
* hourly pricing package.
|
||||
* @return The hourly prices for this item, should this item be part of an
|
||||
hourly pricing package.
|
||||
*/
|
||||
@Nullable
|
||||
public Float getHourlyRecurringFee() {
|
||||
return hourlyRecurringFee;
|
||||
return this.hourlyRecurringFee;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The product item a prices is tied to.
|
||||
*/
|
||||
@Nullable
|
||||
public ProductItem getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return An item's associated item categories.
|
||||
*/
|
||||
public Set<ProductItemCategory> getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The product item a price is tied to.
|
||||
*/
|
||||
public ProductItem getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromPrice(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", itemId=" + itemId + ", recurringFee=" + recurringFee + ", hourlyRecurringFee="
|
||||
+ hourlyRecurringFee + ", item="+item+", categories="+categories+"]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ProductItemPrice that = (ProductItemPrice) o;
|
||||
|
||||
if (id != that.id) return false;
|
||||
|
||||
return true;
|
||||
return this.categories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (id ^ (id >>> 32));
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ProductItemPrice that = ProductItemPrice.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("itemId", itemId).add("recurringFee", recurringFee).add("hourlyRecurringFee", hourlyRecurringFee).add("item", item).add("categories", categories);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,118 +20,135 @@ package org.jclouds.softlayer.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class ProductOrder
|
||||
*
|
||||
* @author Jason King
|
||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Virtual_Guest"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class ProductOrder {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int packageId = -1;
|
||||
private Set<ProductItemPrice> prices = Sets.newLinkedHashSet();
|
||||
private Set<VirtualGuest> virtualGuests = Sets.newLinkedHashSet();
|
||||
private String location;
|
||||
private int quantity;
|
||||
private boolean useHourlyPricing;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromProductOrder(this);
|
||||
}
|
||||
|
||||
public Builder packageId(int packageId) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int packageId;
|
||||
protected String location;
|
||||
protected Set<ProductItemPrice> prices = ImmutableSet.of();
|
||||
protected Set<VirtualGuest> virtualGuests = ImmutableSet.of();
|
||||
protected int quantity;
|
||||
protected boolean useHourlyPricing;
|
||||
|
||||
/**
|
||||
* @see ProductOrder#getPackageId()
|
||||
*/
|
||||
public T packageId(int packageId) {
|
||||
this.packageId = packageId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a price to the order
|
||||
* All that is required to send in is the price ID of each item desired to be ordered.
|
||||
* @param prices
|
||||
* The Prices of the item desired to be ordered
|
||||
* @see ProductOrder#getLocation()
|
||||
*/
|
||||
public Builder price(ProductItemPrice prices) {
|
||||
this.prices.add(checkNotNull(prices, "prices"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple prices to the order, overwriting any existing ones
|
||||
* All that is required to send in is the price ID of each item desired to be ordered.
|
||||
* @param prices
|
||||
* The Prices of the items desired to be ordered
|
||||
*/
|
||||
public Builder prices(Iterable<ProductItemPrice> prices) {
|
||||
this.prices = ImmutableSet.<ProductItemPrice> copyOf(checkNotNull(prices, "prices"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a virtualGuest to the order
|
||||
* @param virtualGuest
|
||||
* The virtualGuest to add. Needs domain and hostname.
|
||||
*/
|
||||
public Builder virtualGuest(VirtualGuest virtualGuest) {
|
||||
this.virtualGuests.add(checkNotNull(virtualGuest, "virtualGuest"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder virtualGuests(Iterable<VirtualGuest> virtualGuests) {
|
||||
this.virtualGuests = ImmutableSet.<VirtualGuest> copyOf(checkNotNull(virtualGuests, "virtualGuests"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder location(String location) {
|
||||
public T location(String location) {
|
||||
this.location = location;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder quantity(int quantity) {
|
||||
/**
|
||||
* @see ProductOrder#getPrices()
|
||||
*/
|
||||
public T prices(Iterable<ProductItemPrice> prices) {
|
||||
this.prices = ImmutableSet.copyOf(checkNotNull(prices, "prices"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T prices(ProductItemPrice... in) {
|
||||
return prices(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductOrder#getVirtualGuests()
|
||||
*/
|
||||
public T virtualGuests(Set<VirtualGuest> virtualGuests) {
|
||||
this.virtualGuests = ImmutableSet.copyOf(checkNotNull(virtualGuests, "virtualGuests"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T virtualGuests(VirtualGuest... in) {
|
||||
return virtualGuests(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductOrder#getQuantity()
|
||||
*/
|
||||
public T quantity(int quantity) {
|
||||
this.quantity = quantity;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder useHourlyPricing(Boolean useHourlyPricing) {
|
||||
/**
|
||||
* @see ProductOrder#getUseHourlyPricing()
|
||||
*/
|
||||
public T useHourlyPricing(boolean useHourlyPricing) {
|
||||
this.useHourlyPricing = useHourlyPricing;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ProductOrder build() {
|
||||
return new ProductOrder(packageId, location,prices, virtualGuests, quantity, useHourlyPricing);
|
||||
return new ProductOrder(packageId, location, prices, virtualGuests, quantity, useHourlyPricing);
|
||||
}
|
||||
|
||||
public static Builder fromProductOrder(ProductOrder in) {
|
||||
return ProductOrder.builder().packageId(in.getPackageId())
|
||||
.location(in.getLocation())
|
||||
.prices(in.getPrices())
|
||||
.virtualGuests(in.getVirtualGuests())
|
||||
.quantity(in.getQuantity())
|
||||
.useHourlyPricing(in.getUseHourlyPricing());
|
||||
public T fromProductOrder(ProductOrder in) {
|
||||
return this
|
||||
.packageId(in.getPackageId())
|
||||
.location(in.getLocation())
|
||||
.prices(in.getPrices())
|
||||
.virtualGuests(in.getVirtualGuests())
|
||||
.quantity(in.getQuantity())
|
||||
.useHourlyPricing(in.getUseHourlyPricing());
|
||||
}
|
||||
}
|
||||
|
||||
private int packageId = -1;
|
||||
private String location;
|
||||
private Set<ProductItemPrice> prices = Sets.newLinkedHashSet();
|
||||
private Set<VirtualGuest> virtualGuests = Sets.newLinkedHashSet();
|
||||
private int quantity;
|
||||
private boolean useHourlyPricing;
|
||||
|
||||
// for deserializer
|
||||
ProductOrder() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public ProductOrder(int packageId, String location, Iterable<ProductItemPrice> prices, Iterable<VirtualGuest> virtualGuest, int quantity, boolean useHourlyPricing) {
|
||||
private final int packageId;
|
||||
private final String location;
|
||||
private final Set<ProductItemPrice> prices;
|
||||
private final Set<VirtualGuest> virtualGuests;
|
||||
private final int quantity;
|
||||
private final boolean useHourlyPricing;
|
||||
|
||||
@ConstructorProperties({
|
||||
"packageId", "location", "prices", "virtualGuest", "quantity", "useHourlyPricing"
|
||||
})
|
||||
protected ProductOrder(int packageId, @Nullable String location, @Nullable Set<ProductItemPrice> prices, @Nullable Set<VirtualGuest> virtualGuests, int quantity, boolean useHourlyPricing) {
|
||||
this.packageId = packageId;
|
||||
this.location = location;
|
||||
this.prices = ImmutableSet.<ProductItemPrice> copyOf(checkNotNull(prices, "prices"));
|
||||
this.virtualGuests = ImmutableSet.<VirtualGuest> copyOf(checkNotNull(virtualGuest, "virtualGuest"));
|
||||
this.prices = prices == null ? ImmutableSet.<ProductItemPrice>of() : ImmutableSet.copyOf(prices);
|
||||
this.virtualGuests = virtualGuests == null ? ImmutableSet.<VirtualGuest>of() : ImmutableSet.copyOf(virtualGuests);
|
||||
this.quantity = quantity;
|
||||
this.useHourlyPricing = useHourlyPricing;
|
||||
}
|
||||
|
@ -140,79 +157,70 @@ public class ProductOrder {
|
|||
* @return The package id of an order. This is required.
|
||||
*/
|
||||
public int getPackageId() {
|
||||
return packageId;
|
||||
return this.packageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The region keyname or specific location keyname where the order should be provisioned.
|
||||
*/
|
||||
@Nullable
|
||||
public String getLocation() {
|
||||
return location;
|
||||
return this.location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item prices in this order.
|
||||
* All that is required to be present is the price ID
|
||||
* All that is required to be present is the prices ID
|
||||
*
|
||||
* @return the prices.
|
||||
*/
|
||||
public Set<ProductItemPrice> getPrices() {
|
||||
return prices;
|
||||
return this.prices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the virtual guests in this order.
|
||||
*
|
||||
* @return the the virtual guests.
|
||||
*/
|
||||
public Set<VirtualGuest> getVirtualGuests() {
|
||||
return virtualGuests;
|
||||
return this.virtualGuests;
|
||||
}
|
||||
|
||||
public int getQuantity() {
|
||||
return quantity;
|
||||
return this.quantity;
|
||||
}
|
||||
|
||||
public boolean getUseHourlyPricing() {
|
||||
return useHourlyPricing;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromProductOrder(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ProductOrder that = (ProductOrder) o;
|
||||
|
||||
if (packageId != that.packageId) return false;
|
||||
if (quantity != that.quantity) return false;
|
||||
if (useHourlyPricing != that.useHourlyPricing) return false;
|
||||
if (location != null ? !location.equals(that.location) : that.location != null)
|
||||
return false;
|
||||
if (prices != null ? !prices.equals(that.prices) : that.prices != null)
|
||||
return false;
|
||||
if (virtualGuests != null ? !virtualGuests.equals(that.virtualGuests) : that.virtualGuests != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return this.useHourlyPricing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (packageId ^ (packageId >>> 32));
|
||||
result = 31 * result + (location != null ? location.hashCode() : 0);
|
||||
result = 31 * result + (prices != null ? prices.hashCode() : 0);
|
||||
result = 31 * result + (virtualGuests != null ? virtualGuests.hashCode() : 0);
|
||||
result = 31 * result + (quantity ^ (quantity >>> 32));
|
||||
result = 31 * result + (useHourlyPricing ? 1 : 0);
|
||||
return result;
|
||||
return Objects.hashCode(packageId, location, prices, virtualGuests, quantity, useHourlyPricing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ProductOrder that = ProductOrder.class.cast(obj);
|
||||
return Objects.equal(this.packageId, that.packageId)
|
||||
&& Objects.equal(this.location, that.location)
|
||||
&& Objects.equal(this.prices, that.prices)
|
||||
&& Objects.equal(this.virtualGuests, that.virtualGuests)
|
||||
&& Objects.equal(this.quantity, that.quantity)
|
||||
&& Objects.equal(this.useHourlyPricing, that.useHourlyPricing);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("packageId", packageId).add("location", location).add("prices", prices).add("virtualGuests", virtualGuests).add("quantity", quantity).add("useHourlyPricing", useHourlyPricing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[packageId=" + packageId + ", location=" + location + ", prices=" + prices
|
||||
+ ", virtualGuests=" + virtualGuests +", quantity=" + quantity + ", useHourlyPricing=" + useHourlyPricing + "]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,63 +18,86 @@
|
|||
*/
|
||||
package org.jclouds.softlayer.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class ProductOrderReceipt
|
||||
*
|
||||
* @author Jason King
|
||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Receipt"
|
||||
* />
|
||||
/>
|
||||
*/
|
||||
public class ProductOrderReceipt implements Comparable<ProductOrderReceipt> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public class ProductOrderReceipt {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int orderId = -1;
|
||||
private ProductOrder orderDetails;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromProductOrderReceipt(this);
|
||||
}
|
||||
|
||||
public Builder orderId(int orderId) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int orderId;
|
||||
protected ProductOrder orderDetails;
|
||||
|
||||
/**
|
||||
* @see ProductOrderReceipt#getOrderId()
|
||||
*/
|
||||
public T orderId(int orderId) {
|
||||
this.orderId = orderId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder orderDetails(ProductOrder orderDetails) {
|
||||
/**
|
||||
* @see ProductOrderReceipt#getOrderDetails()
|
||||
*/
|
||||
public T orderDetails(ProductOrder orderDetails) {
|
||||
this.orderDetails = orderDetails;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ProductOrderReceipt build() {
|
||||
return new ProductOrderReceipt(orderId,orderDetails);
|
||||
return new ProductOrderReceipt(orderId, orderDetails);
|
||||
}
|
||||
|
||||
public static Builder fromAddress(ProductOrderReceipt in) {
|
||||
return ProductOrderReceipt.builder().orderId(in.getOrderId()).orderDetails(in.getOrderDetails());
|
||||
public T fromProductOrderReceipt(ProductOrderReceipt in) {
|
||||
return this
|
||||
.orderId(in.getOrderId())
|
||||
.orderDetails(in.getOrderDetails());
|
||||
}
|
||||
}
|
||||
|
||||
private int orderId = -1;
|
||||
private ProductOrder orderDetails;
|
||||
|
||||
// for deserializer
|
||||
ProductOrderReceipt() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public ProductOrderReceipt(int orderId,ProductOrder orderDetails) {
|
||||
private final int orderId;
|
||||
private final ProductOrder orderDetails;
|
||||
|
||||
@ConstructorProperties({
|
||||
"orderId", "orderDetails"
|
||||
})
|
||||
protected ProductOrderReceipt(int orderId, @Nullable ProductOrder orderDetails) {
|
||||
this.orderId = orderId;
|
||||
this.orderDetails = orderDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ProductOrderReceipt arg0) {
|
||||
return Integer.valueOf(orderId).compareTo(arg0.getOrderId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return unique identifier for the order.
|
||||
*/
|
||||
public int getOrderId() {
|
||||
return orderId;
|
||||
return this.orderId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,40 +106,33 @@ public class ProductOrderReceipt implements Comparable<ProductOrderReceipt> {
|
|||
* This will only return when an order is processed successfully.
|
||||
* It will contain all the items in an order as well as the order totals.
|
||||
*/
|
||||
@Nullable
|
||||
public ProductOrder getOrderDetails() {
|
||||
return orderDetails;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromAddress(this);
|
||||
return this.orderDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (orderId ^ (orderId >>> 32));
|
||||
return result;
|
||||
return Objects.hashCode(orderId, orderDetails);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ProductOrderReceipt other = (ProductOrderReceipt) obj;
|
||||
if (orderId != other.orderId)
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ProductOrderReceipt that = ProductOrderReceipt.class.cast(obj);
|
||||
return Objects.equal(this.orderId, that.orderId)
|
||||
&& Objects.equal(this.orderDetails, that.orderDetails);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("orderId", orderId).add("orderDetails", orderDetails);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[orderId=" + orderId + ", orderDetails="+orderDetails+"]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,10 +20,14 @@ package org.jclouds.softlayer.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* The SoftLayer_Product_Package data type contains information about packages
|
||||
|
@ -33,156 +37,174 @@ import com.google.common.collect.Sets;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href=
|
||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Package"
|
||||
* />
|
||||
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Package"
|
||||
/>
|
||||
*/
|
||||
public class ProductPackage implements Comparable<ProductPackage> {
|
||||
public class ProductPackage {
|
||||
|
||||
// TODO there are more elements than this.
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int id = -1;
|
||||
private String name;
|
||||
private String description;
|
||||
private Set<ProductItem> items = Sets.newLinkedHashSet();
|
||||
private Set<Datacenter> datacenters = Sets.newLinkedHashSet();
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromProductPackage(this);
|
||||
}
|
||||
|
||||
public Builder id(int id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int id;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected Set<ProductItem> items = ImmutableSet.of();
|
||||
protected Set<Datacenter> locations = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see ProductPackage#getId()
|
||||
*/
|
||||
public T id(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see ProductPackage#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see ProductPackage#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder items(Iterable<ProductItem> items) {
|
||||
this.items = ImmutableSet.<ProductItem> copyOf(checkNotNull(items, "items"));
|
||||
return this;
|
||||
/**
|
||||
* @see ProductPackage#getItems()
|
||||
*/
|
||||
public T items(Set<ProductItem> items) {
|
||||
this.items = ImmutableSet.copyOf(checkNotNull(items, "items"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder datacenters(Iterable<Datacenter> datacenters) {
|
||||
this.datacenters = ImmutableSet.<Datacenter> copyOf(checkNotNull(datacenters, "datacenters"));
|
||||
return this;
|
||||
public T items(ProductItem... in) {
|
||||
return items(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ProductPackage#getDatacenters()
|
||||
*/
|
||||
public T datacenters(Set<Datacenter> locations) {
|
||||
this.locations = ImmutableSet.copyOf(checkNotNull(locations, "locations"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T datacenters(Datacenter... in) {
|
||||
return datacenters(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public ProductPackage build() {
|
||||
return new ProductPackage(id, name, description, items, datacenters);
|
||||
return new ProductPackage(id, name, description, items, locations);
|
||||
}
|
||||
|
||||
public static Builder fromProductPackage(ProductPackage in) {
|
||||
return ProductPackage.builder().id(in.getId())
|
||||
.name(in.getName())
|
||||
.description(in.getDescription())
|
||||
.items(in.getItems())
|
||||
.datacenters(in.getDatacenters());
|
||||
public T fromProductPackage(ProductPackage in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.description(in.getDescription())
|
||||
.items(in.getItems())
|
||||
.datacenters(in.getDatacenters());
|
||||
}
|
||||
}
|
||||
|
||||
private int id = -1;
|
||||
private String name;
|
||||
private String description;
|
||||
private Set<ProductItem> items = Sets.newLinkedHashSet();
|
||||
private Set<Datacenter> locations = Sets.newLinkedHashSet();
|
||||
|
||||
// for deserializer
|
||||
ProductPackage() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public ProductPackage(int id, String name, String description, Iterable<ProductItem> items, Iterable<Datacenter> datacenters) {
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final Set<ProductItem> items;
|
||||
private final Set<Datacenter> locations;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "name", "description", "items", "locations"
|
||||
})
|
||||
protected ProductPackage(int id, @Nullable String name, @Nullable String description, @Nullable Set<ProductItem> items, Set<Datacenter> locations) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.items = ImmutableSet.<ProductItem> copyOf(checkNotNull(items, "items"));
|
||||
this.locations = ImmutableSet.<Datacenter> copyOf(checkNotNull(datacenters, "datacenters"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ProductPackage arg0) {
|
||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
||||
this.items = items == null ? ImmutableSet.<ProductItem>of() : ImmutableSet.copyOf(items);
|
||||
this.locations = locations == null ? ImmutableSet.<Datacenter>of() : ImmutableSet.copyOf(locations);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A package's internal identifier. Everything regarding a
|
||||
* SoftLayer_Product_Package is tied back to this id.
|
||||
SoftLayer_Product_Package is tied back to this id.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The description of the package. For server packages, this is
|
||||
* usually a detailed description of processor type and count.
|
||||
usually a detailed description of processor type and count.
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A generic description of the processor type and count. This
|
||||
* includes HTML, so you may want to strip these tags if you plan to
|
||||
* use it.
|
||||
includes HTML, so you may want to strip these tags if you plan to
|
||||
use it.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return A collection of valid items available for purchase in this
|
||||
* package.
|
||||
package.
|
||||
*/
|
||||
public Set<ProductItem> getItems() {
|
||||
return items;
|
||||
return this.items;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return A collection of valid locations for this package.
|
||||
*/
|
||||
public Set<Datacenter> getDatacenters() {
|
||||
return locations;
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromProductPackage(this);
|
||||
return this.locations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id ^ (id >>> 32));
|
||||
return result;
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ProductPackage other = (ProductPackage) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ProductPackage that = ProductPackage.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("description", description).add("items", items).add("locations", locations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProductPackage [id=" + id + ", name=" + name + ", description=" + description + ", items=" + items + ", datacenters=" + locations + "]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,12 @@ package org.jclouds.softlayer.domain;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Strings.emptyToNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* A region is made up of a keyname and a description of that region.
|
||||
* A region keyname can be used as part of an order.
|
||||
|
@ -50,28 +56,25 @@ public class Region implements Comparable<Region> {
|
|||
}
|
||||
|
||||
public Region build() {
|
||||
return new Region(keyname, description);
|
||||
return new Region(0, keyname, description);
|
||||
}
|
||||
|
||||
public static Builder fromAddress(Region in) {
|
||||
return Region.builder().keyname(in.getKeyname())
|
||||
.description(in.getDescription());
|
||||
.description(in.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
/* An integer representing the order in which this element is displayed */
|
||||
private int sortOrder = 0;
|
||||
private String keyname;
|
||||
private String description;
|
||||
private final int sortOrder;
|
||||
private final String keyname;
|
||||
private final String description;
|
||||
|
||||
// for deserializer
|
||||
Region() {
|
||||
|
||||
}
|
||||
|
||||
public Region(String keyname, String description) {
|
||||
this.keyname = checkNotNull(emptyToNull(keyname),"keyname cannot be null or empty:"+keyname);
|
||||
this.description = checkNotNull(emptyToNull(description),"country cannot be null or empty:"+description);
|
||||
@ConstructorProperties({"sortOrder", "keyname", "description"})
|
||||
public Region(int sortOrder, String keyname, String description) {
|
||||
this.sortOrder = sortOrder;
|
||||
this.keyname = checkNotNull(emptyToNull(keyname), "keyname cannot be null or empty:" + keyname);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,6 +92,7 @@ public class Region implements Comparable<Region> {
|
|||
/**
|
||||
* @return A short description of a region's name. This description is seen on the order forms.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
@ -103,26 +107,19 @@ public class Region implements Comparable<Region> {
|
|||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Region region = (Region) o;
|
||||
|
||||
if (sortOrder != region.sortOrder) return false;
|
||||
if (!description.equals(region.description)) return false;
|
||||
if (!keyname.equals(region.keyname)) return false;
|
||||
|
||||
return true;
|
||||
return Objects.equal(keyname, region.keyname)
|
||||
&& Objects.equal(description, region.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = sortOrder;
|
||||
result = 31 * result + keyname.hashCode();
|
||||
result = 31 * result + description.hashCode();
|
||||
return result;
|
||||
return Objects.hashCode(keyname, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[keyname=" + keyname + ", description=" + description + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,10 +20,14 @@ package org.jclouds.softlayer.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* The virtual guest data type presents the structure in which all virtual guests will be presented.
|
||||
|
@ -42,199 +46,13 @@ import com.google.gson.annotations.SerializedName;
|
|||
* The domain portion must consist of least one label followed by a period '.' then ending with the TLD label.
|
||||
* Combining the hostname, followed by a period '.', followed by the domain gives the FQDN (fully qualified domain name),
|
||||
* which may not exceed 253 characters in total length.
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href=
|
||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest"
|
||||
* />
|
||||
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest"
|
||||
/>
|
||||
*/
|
||||
public class VirtualGuest implements Comparable<VirtualGuest> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int id = -1;
|
||||
private int accountId = -1;
|
||||
private Date createDate;
|
||||
private boolean dedicatedAccountHostOnly;
|
||||
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 int billingItemId;
|
||||
private OperatingSystem operatingSystem;
|
||||
private Datacenter datacenter;
|
||||
private PowerState powerState;
|
||||
|
||||
public Builder id(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder accountId(int accountId) {
|
||||
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;
|
||||
}
|
||||
|
||||
public Builder hostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
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 billingItemId(int billingItemId) {
|
||||
this.billingItemId = billingItemId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder operatingSystem(OperatingSystem operatingSystem) {
|
||||
this.operatingSystem = operatingSystem;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder datacenter(Datacenter datacenter) {
|
||||
this.datacenter = datacenter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder powerState(PowerState powerState) {
|
||||
this.powerState = powerState;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VirtualGuest build() {
|
||||
return new VirtualGuest(accountId, createDate, dedicatedAccountHostOnly, domain,
|
||||
fullyQualifiedDomainName, hostname, id, lastVerifiedDate, maxCpu,
|
||||
maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes,
|
||||
privateNetworkOnly, startCpus, statusId, uuid, primaryBackendIpAddress,
|
||||
primaryIpAddress, billingItemId,operatingSystem,datacenter,powerState);
|
||||
}
|
||||
|
||||
public static Builder fromVirtualGuest(VirtualGuest in) {
|
||||
return VirtualGuest.builder()
|
||||
.accountId(in.getAccountId())
|
||||
.createDate(in.getCreateDate())
|
||||
.dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly())
|
||||
.domain(in.getDomain())
|
||||
.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())
|
||||
.billingItemId(in.getBillingItemId())
|
||||
.operatingSystem(in.getOperatingSystem())
|
||||
.datacenter(in.getDatacenter())
|
||||
.powerState(in.getPowerState());
|
||||
}
|
||||
}
|
||||
public class VirtualGuest {
|
||||
|
||||
/**
|
||||
* These states come from the powerState field. i.e.
|
||||
|
@ -260,44 +78,325 @@ public class VirtualGuest implements Comparable<VirtualGuest> {
|
|||
}
|
||||
}
|
||||
|
||||
private int accountId = -1;
|
||||
private Date createDate;
|
||||
@SerializedName("dedicatedAccountHostOnlyFlag")
|
||||
private boolean dedicatedAccountHostOnly;
|
||||
private String domain;
|
||||
private String fullyQualifiedDomainName;
|
||||
private String hostname;
|
||||
private int id = -1;
|
||||
private Date lastVerifiedDate;
|
||||
private int maxCpu = -1;
|
||||
private String maxCpuUnits;
|
||||
private int maxMemory = -1;
|
||||
private Date metricPollDate;
|
||||
private Date modifyDate;
|
||||
private String notes;
|
||||
@SerializedName("privateNetworkOnlyFlag")
|
||||
private boolean privateNetworkOnly;
|
||||
private int startCpus = -1;
|
||||
private int statusId = -1;
|
||||
private String uuid;
|
||||
private String primaryBackendIpAddress;
|
||||
private String primaryIpAddress;
|
||||
public static class BillingItem {
|
||||
private final int id;
|
||||
|
||||
private int billingItemId = -1;
|
||||
private OperatingSystem operatingSystem;
|
||||
private Datacenter datacenter;
|
||||
private PowerState powerState;
|
||||
@ConstructorProperties("id")
|
||||
public BillingItem(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + "]";
|
||||
}
|
||||
}
|
||||
|
||||
// for deserializer
|
||||
VirtualGuest() {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public VirtualGuest(int accountId, Date createDate, boolean dedicatedAccountHostOnly, String domain,
|
||||
String fullyQualifiedDomainName, String hostname, int id, Date lastVerifiedDate, int maxCpu,
|
||||
String maxCpuUnits, int maxMemory, Date metricPollDate, Date modifyDate, String notes,
|
||||
boolean privateNetworkOnly, int startCpus, int statusId, String uuid, String primaryBackendIpAddress,
|
||||
String primaryIpAddress,int billingItemId, OperatingSystem operatingSystem, Datacenter datacenter, PowerState powerState) {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromVirtualGuest(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int accountId;
|
||||
protected Date createDate;
|
||||
protected boolean dedicatedAccountHostOnly;
|
||||
protected String domain;
|
||||
protected String fullyQualifiedDomainName;
|
||||
protected String hostname;
|
||||
protected int id;
|
||||
protected Date lastVerifiedDate;
|
||||
protected int maxCpu;
|
||||
protected String maxCpuUnits;
|
||||
protected int maxMemory;
|
||||
protected Date metricPollDate;
|
||||
protected Date modifyDate;
|
||||
protected String notes;
|
||||
protected boolean privateNetworkOnly;
|
||||
protected int startCpus;
|
||||
protected int statusId;
|
||||
protected String uuid;
|
||||
protected String primaryBackendIpAddress;
|
||||
protected String primaryIpAddress;
|
||||
protected int billingItemId;
|
||||
protected OperatingSystem operatingSystem;
|
||||
protected Datacenter datacenter;
|
||||
protected PowerState powerState;
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getAccountId()
|
||||
*/
|
||||
public T accountId(int accountId) {
|
||||
this.accountId = accountId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getCreateDate()
|
||||
*/
|
||||
public T createDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#isDedicatedAccountHostOnly()
|
||||
*/
|
||||
public T dedicatedAccountHostOnly(boolean dedicatedAccountHostOnly) {
|
||||
this.dedicatedAccountHostOnly = dedicatedAccountHostOnly;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getFullyQualifiedDomainName()
|
||||
*/
|
||||
public T fullyQualifiedDomainName(String fullyQualifiedDomainName) {
|
||||
this.fullyQualifiedDomainName = fullyQualifiedDomainName;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getHostname()
|
||||
*/
|
||||
public T hostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getId()
|
||||
*/
|
||||
public T id(int id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getLastVerifiedDate()
|
||||
*/
|
||||
public T lastVerifiedDate(Date lastVerifiedDate) {
|
||||
this.lastVerifiedDate = lastVerifiedDate;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getMaxCpu()
|
||||
*/
|
||||
public T maxCpu(int maxCpu) {
|
||||
this.maxCpu = maxCpu;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getMaxCpuUnits()
|
||||
*/
|
||||
public T maxCpuUnits(String maxCpuUnits) {
|
||||
this.maxCpuUnits = maxCpuUnits;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getMaxMemory()
|
||||
*/
|
||||
public T maxMemory(int maxMemory) {
|
||||
this.maxMemory = maxMemory;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getMetricPollDate()
|
||||
*/
|
||||
public T metricPollDate(Date metricPollDate) {
|
||||
this.metricPollDate = metricPollDate;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getModifyDate()
|
||||
*/
|
||||
public T modifyDate(Date modifyDate) {
|
||||
this.modifyDate = modifyDate;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getNotes()
|
||||
*/
|
||||
public T notes(String notes) {
|
||||
this.notes = notes;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#isPrivateNetworkOnly()
|
||||
*/
|
||||
public T privateNetworkOnly(boolean privateNetworkOnly) {
|
||||
this.privateNetworkOnly = privateNetworkOnly;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getStartCpus()
|
||||
*/
|
||||
public T startCpus(int startCpus) {
|
||||
this.startCpus = startCpus;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getStatusId()
|
||||
*/
|
||||
public T statusId(int statusId) {
|
||||
this.statusId = statusId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getUuid()
|
||||
*/
|
||||
public T uuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getPrimaryBackendIpAddress()
|
||||
*/
|
||||
public T primaryBackendIpAddress(String primaryBackendIpAddress) {
|
||||
this.primaryBackendIpAddress = primaryBackendIpAddress;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getPrimaryIpAddress()
|
||||
*/
|
||||
public T primaryIpAddress(String primaryIpAddress) {
|
||||
this.primaryIpAddress = primaryIpAddress;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getBillingItemId()
|
||||
*/
|
||||
public T billingItemId(int billingItemId) {
|
||||
this.billingItemId = billingItemId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getOperatingSystem()
|
||||
*/
|
||||
public T operatingSystem(OperatingSystem operatingSystem) {
|
||||
this.operatingSystem = operatingSystem;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getDatacenter()
|
||||
*/
|
||||
public T datacenter(Datacenter datacenter) {
|
||||
this.datacenter = datacenter;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getPowerState()
|
||||
*/
|
||||
public T powerState(PowerState powerState) {
|
||||
this.powerState = powerState;
|
||||
return self();
|
||||
}
|
||||
|
||||
public VirtualGuest build() {
|
||||
return new VirtualGuest(accountId, createDate, dedicatedAccountHostOnly, domain, fullyQualifiedDomainName, hostname,
|
||||
id, lastVerifiedDate, maxCpu, maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes, privateNetworkOnly,
|
||||
startCpus, statusId, uuid, primaryBackendIpAddress, primaryIpAddress, new BillingItem(billingItemId),
|
||||
operatingSystem, datacenter, powerState);
|
||||
}
|
||||
|
||||
public T fromVirtualGuest(VirtualGuest in) {
|
||||
return this
|
||||
.accountId(in.getAccountId())
|
||||
.createDate(in.getCreateDate())
|
||||
.dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly())
|
||||
.domain(in.getDomain())
|
||||
.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())
|
||||
.billingItemId(in.getBillingItemId())
|
||||
.operatingSystem(in.getOperatingSystem())
|
||||
.datacenter(in.getDatacenter())
|
||||
.powerState(in.getPowerState());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final int accountId;
|
||||
private final Date createDate;
|
||||
private final boolean dedicatedAccountHostOnly;
|
||||
private final String domain;
|
||||
private final String fullyQualifiedDomainName;
|
||||
private final String hostname;
|
||||
private final int id;
|
||||
private final Date lastVerifiedDate;
|
||||
private final int maxCpu;
|
||||
private final String maxCpuUnits;
|
||||
private final int maxMemory;
|
||||
private final Date metricPollDate;
|
||||
private final Date modifyDate;
|
||||
private final String notes;
|
||||
private final boolean privateNetworkOnly;
|
||||
private final int startCpus;
|
||||
private final int statusId;
|
||||
private final String uuid;
|
||||
private final String primaryBackendIpAddress;
|
||||
private final String primaryIpAddress;
|
||||
private final int billingItemId;
|
||||
private final OperatingSystem operatingSystem;
|
||||
private final Datacenter datacenter;
|
||||
private final PowerState powerState;
|
||||
|
||||
@ConstructorProperties({
|
||||
"accountId", "createDate", "dedicatedAccountHostOnlyFlag", "domain", "fullyQualifiedDomainName", "hostname", "id", "lastVerifiedDate", "maxCpu", "maxCpuUnits", "maxMemory", "metricPollDate", "modifyDate", "notes", "privateNetworkOnlyFlag", "startCpus", "statusId", "uuid", "primaryBackendIpAddress", "primaryIpAddress", "billingItem", "operatingSystem", "datacenter", "powerState"
|
||||
})
|
||||
protected VirtualGuest(int accountId, @Nullable Date createDate, boolean dedicatedAccountHostOnly, @Nullable String domain,
|
||||
@Nullable String fullyQualifiedDomainName, @Nullable String hostname, int id, @Nullable Date lastVerifiedDate,
|
||||
int maxCpu, @Nullable String maxCpuUnits, int maxMemory, @Nullable Date metricPollDate, @Nullable Date modifyDate,
|
||||
@Nullable String notes, boolean privateNetworkOnly, int startCpus, int statusId, @Nullable String uuid,
|
||||
@Nullable String primaryBackendIpAddress, @Nullable String primaryIpAddress, @Nullable BillingItem billingItem,
|
||||
@Nullable OperatingSystem operatingSystem, @Nullable Datacenter datacenter, @Nullable PowerState powerState) {
|
||||
this.accountId = accountId;
|
||||
this.createDate = createDate;
|
||||
this.dedicatedAccountHostOnly = dedicatedAccountHostOnly;
|
||||
|
@ -318,336 +417,241 @@ public class VirtualGuest implements Comparable<VirtualGuest> {
|
|||
this.uuid = uuid;
|
||||
this.primaryBackendIpAddress = primaryBackendIpAddress;
|
||||
this.primaryIpAddress = primaryIpAddress;
|
||||
this.billingItemId = billingItemId;
|
||||
this.billingItemId = billingItem == null ? -1 : billingItem.id;
|
||||
this.operatingSystem = operatingSystem;
|
||||
this.datacenter = datacenter;
|
||||
this.powerState = powerState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(VirtualGuest arg0) {
|
||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A computing instance's associated account id
|
||||
*/
|
||||
public int getAccountId() {
|
||||
return accountId;
|
||||
return this.accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The date a virtual computing instance was created.
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
return this.createDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return When true this flag specifies that a compute instance is to run on hosts that only
|
||||
* have guests from the same account.
|
||||
have guests from the same account.
|
||||
*/
|
||||
public boolean isDedicatedAccountHostOnly() {
|
||||
return dedicatedAccountHostOnly;
|
||||
return this.dedicatedAccountHostOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A computing instance's domain name
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A name reflecting the hostname and domain of the computing instance.
|
||||
*/
|
||||
@Nullable
|
||||
public String getFullyQualifiedDomainName() {
|
||||
return fullyQualifiedDomainName;
|
||||
return this.fullyQualifiedDomainName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A virtual computing instance's hostname
|
||||
*/
|
||||
@Nullable
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
return this.hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Unique ID for a computing instance.
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The last timestamp of when the guest was verified as a resident virtual machine on the
|
||||
* host's hypervisor platform.
|
||||
host's hypervisor platform.
|
||||
*/
|
||||
|
||||
@Nullable
|
||||
public Date getLastVerifiedDate() {
|
||||
return lastVerifiedDate;
|
||||
return this.lastVerifiedDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The maximum amount of CPU resources a computing instance may utilize.
|
||||
*/
|
||||
public int getMaxCpu() {
|
||||
return maxCpu;
|
||||
return this.maxCpu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The unit of the maximum amount of CPU resources a computing instance may utilize.
|
||||
*/
|
||||
@Nullable
|
||||
public String getMaxCpuUnits() {
|
||||
return maxCpuUnits;
|
||||
return this.maxCpuUnits;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The maximum amount of memory a computing instance may utilize.
|
||||
*/
|
||||
public int getMaxMemory() {
|
||||
return maxMemory;
|
||||
return this.maxMemory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The date of the most recent metric tracking poll performed.
|
||||
*/
|
||||
@Nullable
|
||||
public Date getMetricPollDate() {
|
||||
return metricPollDate;
|
||||
return this.metricPollDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The date a virtual computing instance was last modified.
|
||||
*/
|
||||
@Nullable
|
||||
public Date getModifyDate() {
|
||||
return modifyDate;
|
||||
return this.modifyDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A small note about a cloud instance to use at your discretion.
|
||||
*/
|
||||
@Nullable
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
return this.notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the computing instance only has access to the private network.
|
||||
*/
|
||||
public boolean isPrivateNetworkOnly() {
|
||||
return privateNetworkOnly;
|
||||
return this.privateNetworkOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number of CPUs available to a computing instance upon startup.
|
||||
*/
|
||||
public int getStartCpus() {
|
||||
return startCpus;
|
||||
return this.startCpus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A computing instances status ID
|
||||
*/
|
||||
public int getStatusId() {
|
||||
return statusId;
|
||||
return this.statusId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Unique ID for a computing instance's record on a virtualization platform.
|
||||
*/
|
||||
@Nullable
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return private ip address
|
||||
*/
|
||||
@Nullable
|
||||
public String getPrimaryBackendIpAddress() {
|
||||
return primaryBackendIpAddress;
|
||||
return this.primaryBackendIpAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return public ip address
|
||||
*/
|
||||
@Nullable
|
||||
public String getPrimaryIpAddress() {
|
||||
return primaryIpAddress;
|
||||
return this.primaryIpAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The billing item for a CloudLayer Compute Instance.
|
||||
*/
|
||||
public int getBillingItemId() {
|
||||
return billingItemId;
|
||||
return this.billingItemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A guest's operating system.
|
||||
*/
|
||||
@Nullable
|
||||
public OperatingSystem getOperatingSystem() {
|
||||
return operatingSystem;
|
||||
return this.operatingSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The guest's datacenter
|
||||
*/
|
||||
@Nullable
|
||||
public Datacenter getDatacenter() {
|
||||
return datacenter;
|
||||
return this.datacenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The current power state of a virtual guest.
|
||||
*/
|
||||
@Nullable
|
||||
public PowerState getPowerState() {
|
||||
return powerState;
|
||||
return this.powerState;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (accountId ^ (accountId >>> 32));
|
||||
result = prime * result + ((createDate == null) ? 0 : createDate.hashCode());
|
||||
result = prime * result + (dedicatedAccountHostOnly ? 1231 : 1237);
|
||||
result = prime * result + ((domain == null) ? 0 : domain.hashCode());
|
||||
result = prime * result + ((fullyQualifiedDomainName == null) ? 0 : fullyQualifiedDomainName.hashCode());
|
||||
result = prime * result + ((hostname == null) ? 0 : hostname.hashCode());
|
||||
result = prime * result + (id ^ (id >>> 32));
|
||||
result = prime * result + ((lastVerifiedDate == null) ? 0 : lastVerifiedDate.hashCode());
|
||||
result = prime * result + maxCpu;
|
||||
result = prime * result + ((maxCpuUnits == null) ? 0 : maxCpuUnits.hashCode());
|
||||
result = prime * result + maxMemory;
|
||||
result = prime * result + ((metricPollDate == null) ? 0 : metricPollDate.hashCode());
|
||||
result = prime * result + ((modifyDate == null) ? 0 : modifyDate.hashCode());
|
||||
result = prime * result + ((notes == null) ? 0 : notes.hashCode());
|
||||
result = prime * result + ((primaryBackendIpAddress == null) ? 0 : primaryBackendIpAddress.hashCode());
|
||||
result = prime * result + ((primaryIpAddress == null) ? 0 : primaryIpAddress.hashCode());
|
||||
result = prime * result + (privateNetworkOnly ? 1231 : 1237);
|
||||
result = prime * result + startCpus;
|
||||
result = prime * result + statusId;
|
||||
result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
|
||||
result = prime * result + (getBillingItemId() ^ (getBillingItemId() >>> 32));
|
||||
result = prime * result + ((operatingSystem == null) ? 0 : operatingSystem.hashCode());
|
||||
result = prime * result + ((datacenter == null) ? 0 : datacenter.hashCode());
|
||||
result = prime * result + ((powerState == null) ? 0 : powerState.hashCode());
|
||||
return result;
|
||||
return Objects.hashCode(accountId, createDate, dedicatedAccountHostOnly, domain, fullyQualifiedDomainName, hostname, id, lastVerifiedDate, maxCpu, maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes, privateNetworkOnly, startCpus, statusId, uuid, primaryBackendIpAddress, primaryIpAddress, billingItemId, operatingSystem, datacenter, powerState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VirtualGuest other = (VirtualGuest) obj;
|
||||
if (accountId != other.accountId)
|
||||
return false;
|
||||
if (createDate == null) {
|
||||
if (other.createDate != null)
|
||||
return false;
|
||||
} else if (!createDate.equals(other.createDate))
|
||||
return false;
|
||||
if (dedicatedAccountHostOnly != other.dedicatedAccountHostOnly)
|
||||
return false;
|
||||
if (domain == null) {
|
||||
if (other.domain != null)
|
||||
return false;
|
||||
} else if (!domain.equals(other.domain))
|
||||
return false;
|
||||
if (fullyQualifiedDomainName == null) {
|
||||
if (other.fullyQualifiedDomainName != null)
|
||||
return false;
|
||||
} else if (!fullyQualifiedDomainName.equals(other.fullyQualifiedDomainName))
|
||||
return false;
|
||||
if (hostname == null) {
|
||||
if (other.hostname != null)
|
||||
return false;
|
||||
} else if (!hostname.equals(other.hostname))
|
||||
return false;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
if (lastVerifiedDate == null) {
|
||||
if (other.lastVerifiedDate != null)
|
||||
return false;
|
||||
} else if (!lastVerifiedDate.equals(other.lastVerifiedDate))
|
||||
return false;
|
||||
if (maxCpu != other.maxCpu)
|
||||
return false;
|
||||
if (maxCpuUnits == null) {
|
||||
if (other.maxCpuUnits != null)
|
||||
return false;
|
||||
} else if (!maxCpuUnits.equals(other.maxCpuUnits))
|
||||
return false;
|
||||
if (maxMemory != other.maxMemory)
|
||||
return false;
|
||||
if (metricPollDate == null) {
|
||||
if (other.metricPollDate != null)
|
||||
return false;
|
||||
} else if (!metricPollDate.equals(other.metricPollDate))
|
||||
return false;
|
||||
if (modifyDate == null) {
|
||||
if (other.modifyDate != null)
|
||||
return false;
|
||||
} else if (!modifyDate.equals(other.modifyDate))
|
||||
return false;
|
||||
if (notes == null) {
|
||||
if (other.notes != null)
|
||||
return false;
|
||||
} else if (!notes.equals(other.notes))
|
||||
return false;
|
||||
if (primaryBackendIpAddress == null) {
|
||||
if (other.primaryBackendIpAddress != null)
|
||||
return false;
|
||||
} else if (!primaryBackendIpAddress.equals(other.primaryBackendIpAddress))
|
||||
return false;
|
||||
if (primaryIpAddress == null) {
|
||||
if (other.primaryIpAddress != null)
|
||||
return false;
|
||||
} else if (!primaryIpAddress.equals(other.primaryIpAddress))
|
||||
return false;
|
||||
if (privateNetworkOnly != other.privateNetworkOnly)
|
||||
return false;
|
||||
if (startCpus != other.startCpus)
|
||||
return false;
|
||||
if (statusId != other.statusId)
|
||||
return false;
|
||||
if (uuid == null) {
|
||||
if (other.uuid != null)
|
||||
return false;
|
||||
} else if (!uuid.equals(other.uuid))
|
||||
return false;
|
||||
if (getBillingItemId() != other.getBillingItemId())
|
||||
return false;
|
||||
if (operatingSystem == null) {
|
||||
if (other.operatingSystem != null)
|
||||
return false;
|
||||
} else if (!operatingSystem.equals(other.operatingSystem))
|
||||
return false;
|
||||
if (datacenter == null) {
|
||||
if (other.datacenter != null)
|
||||
return false;
|
||||
} else if (!datacenter.equals(other.datacenter))
|
||||
return false;
|
||||
if (powerState == null) {
|
||||
if (other.powerState != null)
|
||||
return false;
|
||||
} else if (!powerState.equals(other.powerState))
|
||||
return false;
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
VirtualGuest that = VirtualGuest.class.cast(obj);
|
||||
return Objects.equal(this.accountId, that.accountId)
|
||||
&& Objects.equal(this.createDate, that.createDate)
|
||||
&& Objects.equal(this.dedicatedAccountHostOnly, that.dedicatedAccountHostOnly)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.fullyQualifiedDomainName, that.fullyQualifiedDomainName)
|
||||
&& Objects.equal(this.hostname, that.hostname)
|
||||
&& Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.lastVerifiedDate, that.lastVerifiedDate)
|
||||
&& Objects.equal(this.maxCpu, that.maxCpu)
|
||||
&& Objects.equal(this.maxCpuUnits, that.maxCpuUnits)
|
||||
&& Objects.equal(this.maxMemory, that.maxMemory)
|
||||
&& Objects.equal(this.metricPollDate, that.metricPollDate)
|
||||
&& Objects.equal(this.modifyDate, that.modifyDate)
|
||||
&& Objects.equal(this.notes, that.notes)
|
||||
&& Objects.equal(this.privateNetworkOnly, that.privateNetworkOnly)
|
||||
&& Objects.equal(this.startCpus, that.startCpus)
|
||||
&& Objects.equal(this.statusId, that.statusId)
|
||||
&& Objects.equal(this.uuid, that.uuid)
|
||||
&& Objects.equal(this.primaryBackendIpAddress, that.primaryBackendIpAddress)
|
||||
&& Objects.equal(this.primaryIpAddress, that.primaryIpAddress)
|
||||
&& Objects.equal(this.billingItemId, that.billingItemId)
|
||||
&& Objects.equal(this.operatingSystem, that.operatingSystem)
|
||||
&& Objects.equal(this.datacenter, that.datacenter)
|
||||
&& Objects.equal(this.powerState, that.powerState);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("accountId", accountId).add("createDate", createDate).add("dedicatedAccountHostOnly", dedicatedAccountHostOnly).add("domain", domain).add("fullyQualifiedDomainName", fullyQualifiedDomainName).add("hostname", hostname).add("id", id).add("lastVerifiedDate", lastVerifiedDate).add("maxCpu", maxCpu).add("maxCpuUnits", maxCpuUnits).add("maxMemory", maxMemory).add("metricPollDate", metricPollDate).add("modifyDate", modifyDate).add("notes", notes).add("privateNetworkOnly", privateNetworkOnly).add("startCpus", startCpus).add("statusId", statusId).add("uuid", uuid).add("primaryBackendIpAddress", primaryBackendIpAddress).add("primaryIpAddress", primaryIpAddress).add("billingItemId", billingItemId).add("operatingSystem", operatingSystem).add("datacenter", datacenter).add("powerState", powerState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[accountId=" + accountId + ", createDate=" + createDate + ", dedicatedAccountHostOnly="
|
||||
+ dedicatedAccountHostOnly + ", domain=" + domain + ", fullyQualifiedDomainName="
|
||||
+ fullyQualifiedDomainName + ", hostname=" + hostname + ", id=" + id + ", lastVerifiedDate="
|
||||
+ lastVerifiedDate + ", maxCpu=" + maxCpu + ", maxCpuUnits=" + maxCpuUnits + ", maxMemory=" + maxMemory
|
||||
+ ", metricPollDate=" + metricPollDate + ", modifyDate=" + modifyDate + ", notes=" + notes
|
||||
+ ", primaryBackendIpAddress=" + primaryBackendIpAddress + ", primaryIpAddress=" + primaryIpAddress
|
||||
+ ", privateNetworkOnly=" + privateNetworkOnly + ", startCpus=" + startCpus + ", statusId=" + statusId
|
||||
+ ", uuid=" + uuid + ", billingItemId="+getBillingItemId()+", operatingSystem="+operatingSystem+", datacenter="+datacenter
|
||||
+ ", powerState="+powerState+"]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class ProductOrderToJsonTest {
|
|||
.quantity(99)
|
||||
.useHourlyPricing(true)
|
||||
.prices(ImmutableSet.of(price1,price2))
|
||||
.virtualGuest(guest)
|
||||
.virtualGuests(guest)
|
||||
.build();
|
||||
|
||||
String expected = String.format(FORMAT.replaceAll("'","\""),
|
||||
|
|
|
@ -107,7 +107,7 @@ public class ProductItemToImageTest {
|
|||
{
|
||||
ProductItem item = ProductItem.builder()
|
||||
.description(description)
|
||||
.price(ProductItemPrice.builder().id(1234).build())
|
||||
.prices(ProductItemPrice.builder().id(1234).build())
|
||||
.build();
|
||||
Image i = new ProductItemToImage().apply(item);
|
||||
OperatingSystem os = i.getOperatingSystem();
|
||||
|
@ -122,7 +122,7 @@ public class ProductItemToImageTest {
|
|||
public void testUbuntu() {
|
||||
ProductItem item = ProductItem.builder()
|
||||
.description("Ubuntu Linux 10.04 LTS Lucid Lynx - Minimal Install (64 bit)")
|
||||
.price(ProductItemPrice.builder().id(1234).build())
|
||||
.prices(ProductItemPrice.builder().id(1234).build())
|
||||
.build();
|
||||
Image i = new ProductItemToImage().apply(item);
|
||||
OperatingSystem os = i.getOperatingSystem();
|
||||
|
@ -136,7 +136,7 @@ public class ProductItemToImageTest {
|
|||
public void testUbuntuNoBitCount() {
|
||||
ProductItem item = ProductItem.builder()
|
||||
.description("Ubuntu Linux 10.04 LTS Lucid Lynx - Minimal Install")
|
||||
.price(ProductItemPrice.builder().id(1234).build())
|
||||
.prices(ProductItemPrice.builder().id(1234).build())
|
||||
.build();
|
||||
Image i = new ProductItemToImage().apply(item);
|
||||
OperatingSystem os = i.getOperatingSystem();
|
||||
|
@ -151,7 +151,7 @@ public class ProductItemToImageTest {
|
|||
public void testCompletelyUnknown() {
|
||||
ProductItem item = ProductItem.builder()
|
||||
.description("This fails to match anything!!!")
|
||||
.price(ProductItemPrice.builder().id(1234).build())
|
||||
.prices(ProductItemPrice.builder().id(1234).build())
|
||||
.build();
|
||||
Image i = new ProductItemToImage().apply(item);
|
||||
OperatingSystem os = i.getOperatingSystem();
|
||||
|
@ -165,7 +165,7 @@ public class ProductItemToImageTest {
|
|||
public void test64BitUnknown() {
|
||||
ProductItem item = ProductItem.builder()
|
||||
.description("This only has the bit-count (64 bit)")
|
||||
.price(ProductItemPrice.builder().id(1234).build())
|
||||
.prices(ProductItemPrice.builder().id(1234).build())
|
||||
.build();
|
||||
Image i = new ProductItemToImage().apply(item);
|
||||
OperatingSystem os = i.getOperatingSystem();
|
||||
|
@ -183,7 +183,7 @@ public class ProductItemToImageTest {
|
|||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testNoDescription() {
|
||||
ProductItem item = ProductItem.builder()
|
||||
.price(ProductItemPrice.builder().id(1234).build())
|
||||
.prices(ProductItemPrice.builder().id(1234).build())
|
||||
.build();
|
||||
new ProductItemToImage().apply(item);
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class ProductItemToImageTest {
|
|||
@Test
|
||||
public void testId() {
|
||||
ProductItemPrice price = ProductItemPrice.builder().id(1234).build();
|
||||
ProductItem item = ProductItem.builder().price(price).build();
|
||||
ProductItem item = ProductItem.builder().prices(price).build();
|
||||
assertEquals("1234",imageId().apply(item));
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ProductItemsTest {
|
|||
item = ProductItem.builder().id(1)
|
||||
.capacity(2.0f)
|
||||
.description("an item")
|
||||
.price(price)
|
||||
.prices(price)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class ProductItemsTest {
|
|||
@Test
|
||||
public void testItemCallGetsCategory() {
|
||||
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
||||
.category(category)
|
||||
.categories(category)
|
||||
.item(item)
|
||||
.build();
|
||||
ProductItem newItem = item().apply(price);
|
||||
|
@ -114,8 +114,7 @@ public class ProductItemsTest {
|
|||
@Test
|
||||
public void testItemCallNoCategoryOnPrice() {
|
||||
|
||||
ProductItem item1 = ProductItem.Builder.fromProductItem(item)
|
||||
.categories(ImmutableSet.of(category)).build();
|
||||
ProductItem item1 = item.toBuilder().categories(ImmutableSet.of(category)).build();
|
||||
|
||||
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
||||
.item(item1)
|
||||
|
@ -132,11 +131,10 @@ public class ProductItemsTest {
|
|||
.categoryCode("new category")
|
||||
.build();
|
||||
|
||||
ProductItem item1 = ProductItem.Builder.fromProductItem(item)
|
||||
.categories(ImmutableSet.of(category2)).build();
|
||||
ProductItem item1 = item.toBuilder().categories(ImmutableSet.of(category2)).build();
|
||||
|
||||
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
||||
.category(category)
|
||||
.categories(category)
|
||||
.item(item1)
|
||||
.build();
|
||||
ProductItem newItem = item().apply(price);
|
||||
|
|
|
@ -67,26 +67,26 @@ public class ProductItemsToHardwareTest {
|
|||
.id(1)
|
||||
.description("2 x 2.0 GHz Cores")
|
||||
.capacity(2F)
|
||||
.category(ProductItemCategory.builder().categoryCode("guest_core").build())
|
||||
.price(ProductItemPrice.builder().id(123).build())
|
||||
.categories(ProductItemCategory.builder().categoryCode("guest_core").build())
|
||||
.prices(ProductItemPrice.builder().id(123).build())
|
||||
.build();
|
||||
|
||||
ramItem = ProductItem.builder().id(2).description("2GB ram").capacity(2F).category(
|
||||
ProductItemCategory.builder().categoryCode("ram").build()).price(
|
||||
ProductItemPrice.builder().id(456).build()).build();
|
||||
ramItem = ProductItem.builder().id(2).description("2GB ram").capacity(2F).categories(
|
||||
ProductItemCategory.builder().categoryCode("ram").build()).prices(
|
||||
ProductItemPrice.builder().id(456).build()).build();
|
||||
|
||||
volumeItem = ProductItem.builder().id(3).description("100 GB (SAN)").capacity(100F).price(
|
||||
ProductItemPrice.builder().id(789).build()).category(
|
||||
ProductItemCategory.builder().categoryCode("guest_disk0").build()).build();
|
||||
volumeItem = ProductItem.builder().id(3).description("100 GB (SAN)").capacity(100F).prices(
|
||||
ProductItemPrice.builder().id(789).build()).categories(
|
||||
ProductItemCategory.builder().categoryCode("guest_disk0").build()).build();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHardwareId() {
|
||||
ProductItem item1 = ProductItem.builder().price(ProductItemPrice.builder().id(123).build()).build();
|
||||
ProductItem item2 = ProductItem.builder().price(ProductItemPrice.builder().id(456).build()).build();
|
||||
ProductItem item3 = ProductItem.builder().price(ProductItemPrice.builder().id(789).build()).build();
|
||||
ProductItem item1 = ProductItem.builder().prices(ProductItemPrice.builder().id(123).build()).build();
|
||||
ProductItem item2 = ProductItem.builder().prices(ProductItemPrice.builder().id(456).build()).build();
|
||||
ProductItem item3 = ProductItem.builder().prices(ProductItemPrice.builder().id(789).build()).build();
|
||||
|
||||
String id = hardwareId().apply(ImmutableList.of(item1, item2, item3));
|
||||
assertEquals("123,456,789", id);
|
||||
|
@ -138,9 +138,9 @@ public class ProductItemsToHardwareTest {
|
|||
|
||||
@Test
|
||||
public void testHardwareWithTwoDisks() {
|
||||
ProductItem localVolumeItem = ProductItem.builder().id(4).description("25 GB").capacity(25F).price(
|
||||
ProductItemPrice.builder().id(987).build()).category(
|
||||
ProductItemCategory.builder().categoryCode("guest_disk1").build()).build();
|
||||
ProductItem localVolumeItem = ProductItem.builder().id(4).description("25 GB").capacity(25F).prices(
|
||||
ProductItemPrice.builder().id(987).build()).categories(
|
||||
ProductItemCategory.builder().categoryCode("guest_disk1").build()).build();
|
||||
|
||||
Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem,localVolumeItem));
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest {
|
|||
|
||||
for (ProductItemPrice price : item.getPrices()) {
|
||||
// ProductItemPrice newDetails =
|
||||
// client.getProductItemPrice(price.getId());
|
||||
// client.getProductItemPrice(prices.getId());
|
||||
// assertEquals(item.getId(), newDetails.getId());
|
||||
checkPrice(price);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public class VirtualGuestClientLiveTest extends BaseSoftLayerClientLiveTest {
|
|||
TEST_HOSTNAME_PREFIX + new Random().nextInt()).build();
|
||||
|
||||
ProductOrder order = ProductOrder.builder().packageId(pkgId).quantity(1).useHourlyPricing(true).prices(
|
||||
prices.build()).virtualGuest(guest).build();
|
||||
prices.build()).virtualGuests(guest).build();
|
||||
|
||||
ProductOrderReceipt receipt = socontext.getApi().getVirtualGuestClient().orderVirtualGuest(order);
|
||||
ProductOrder order2 = receipt.getOrderDetails();
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ParseVirtualGuestHaltedTest extends BaseItemParserTest<VirtualGuest
|
|||
.primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001)
|
||||
.uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8")
|
||||
.operatingSystem(OperatingSystem.builder().id(913824)
|
||||
.password(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
||||
.passwords(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
||||
.build())
|
||||
.datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build())
|
||||
//TODO: maybe powerState can be flattened like billingItemId
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ParseVirtualGuestPausedTest extends BaseItemParserTest<VirtualGuest
|
|||
.primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001)
|
||||
.uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8")
|
||||
.operatingSystem(OperatingSystem.builder().id(913824)
|
||||
.password(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
||||
.passwords(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
||||
.build())
|
||||
.datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build())
|
||||
//TODO: maybe powerState can be flattened like billingItemId
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ParseVirtualGuestRunningTest extends BaseItemParserTest<VirtualGues
|
|||
.primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001)
|
||||
.uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8")
|
||||
.operatingSystem(OperatingSystem.builder().id(913824)
|
||||
.password(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
||||
.passwords(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
||||
.build())
|
||||
.datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build())
|
||||
//TODO: maybe powerState can be flattened like billingItemId
|
||||
|
|
Loading…
Reference in New Issue