mirror of https://github.com/apache/jclouds.git
Issue 981: better toString on template
This commit is contained in:
parent
1b0d6e027a
commit
3e2e24493e
|
@ -30,6 +30,7 @@ import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -259,7 +260,7 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
|
||||||
private final int memory;
|
private final int memory;
|
||||||
private final boolean haSupport;
|
private final boolean haSupport;
|
||||||
private final StorageType storageType;
|
private final StorageType storageType;
|
||||||
private final String tags;
|
private final Set<String> tags;
|
||||||
private final boolean defaultUse;
|
private final boolean defaultUse;
|
||||||
private final String hostTags;
|
private final String hostTags;
|
||||||
private final boolean systemOffering;
|
private final boolean systemOffering;
|
||||||
|
@ -285,7 +286,8 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
|
||||||
this.memory = memory;
|
this.memory = memory;
|
||||||
this.haSupport = haSupport;
|
this.haSupport = haSupport;
|
||||||
this.storageType = storageType;
|
this.storageType = storageType;
|
||||||
this.tags = tags;
|
this.tags = !(Strings.emptyToNull(tags) == null) ? ImmutableSet.copyOf(Splitter.on(',').split(tags))
|
||||||
|
: ImmutableSet.<String> of();
|
||||||
this.defaultUse = defaultUse;
|
this.defaultUse = defaultUse;
|
||||||
this.hostTags = hostTags;
|
this.hostTags = hostTags;
|
||||||
this.systemOffering = systemOffering;
|
this.systemOffering = systemOffering;
|
||||||
|
@ -377,7 +379,7 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
|
||||||
* @return the tags for the service offering
|
* @return the tags for the service offering
|
||||||
*/
|
*/
|
||||||
public Set<String> getTags() {
|
public Set<String> getTags() {
|
||||||
return tags == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(Splitter.on(',').split(tags));
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,11 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.domain;
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Running Operating system
|
* Running Operating system
|
||||||
|
@ -95,6 +98,33 @@ public class OperatingSystem {
|
||||||
protected String description;
|
protected String description;
|
||||||
protected boolean is64Bit;
|
protected boolean is64Bit;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
OperatingSystem that = OperatingSystem.class.cast(o);
|
||||||
|
return equal(this.family, that.family) && equal(this.name, that.name) && equal(this.arch, that.arch)
|
||||||
|
&& equal(this.version, that.version) && equal(this.description, that.description)
|
||||||
|
&& equal(this.is64Bit, that.is64Bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(family, name, arch, version, description, is64Bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper("").omitNullValues().add("family", family).add("name", name).add("arch", arch)
|
||||||
|
.add("version", version).add("description", description).add("is64Bit", is64Bit);
|
||||||
|
}
|
||||||
|
|
||||||
// for serialization/deserialization
|
// for serialization/deserialization
|
||||||
protected OperatingSystem() {
|
protected OperatingSystem() {
|
||||||
|
|
||||||
|
@ -192,66 +222,8 @@ public class OperatingSystem {
|
||||||
return is64Bit;
|
return is64Bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((arch == null) ? 0 : arch.hashCode());
|
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
|
||||||
result = prime * result + ((family == null) ? 0 : family.hashCode());
|
|
||||||
result = prime * result + (is64Bit ? 1231 : 1237);
|
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
|
||||||
result = prime * result + ((version == null) ? 0 : version.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (!(obj instanceof OperatingSystem))
|
|
||||||
return false;
|
|
||||||
OperatingSystem other = (OperatingSystem) obj;
|
|
||||||
if (arch == null) {
|
|
||||||
if (other.arch != null)
|
|
||||||
return false;
|
|
||||||
} else if (!arch.equals(other.arch))
|
|
||||||
return false;
|
|
||||||
if (description == null) {
|
|
||||||
if (other.description != null)
|
|
||||||
return false;
|
|
||||||
} else if (!description.equals(other.description))
|
|
||||||
return false;
|
|
||||||
if (family == null) {
|
|
||||||
if (other.family != null)
|
|
||||||
return false;
|
|
||||||
} else if (!family.equals(other.family))
|
|
||||||
return false;
|
|
||||||
if (is64Bit != other.is64Bit)
|
|
||||||
return false;
|
|
||||||
if (name == null) {
|
|
||||||
if (other.name != null)
|
|
||||||
return false;
|
|
||||||
} else if (!name.equals(other.name))
|
|
||||||
return false;
|
|
||||||
if (version == null) {
|
|
||||||
if (other.version != null)
|
|
||||||
return false;
|
|
||||||
} else if (!version.equals(other.version))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
public Builder toBuilder() {
|
||||||
return builder().fromOperatingSystem(this);
|
return builder().fromOperatingSystem(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "[name=" + name + ", family=" + family + ", version=" + version + ", arch=" + arch + ", is64Bit="
|
|
||||||
+ is64Bit + ", description=" + description + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,6 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.domain;
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Objects.equal;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ComparisonChain;
|
import com.google.common.collect.ComparisonChain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,36 +68,27 @@ public class Processor implements Comparable<Processor> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public boolean equals(Object o) {
|
||||||
return "[cores=" + cores + ", speed=" + speed + "]";
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
Processor that = Processor.class.cast(o);
|
||||||
|
return equal(this.cores, that.cores) && equal(this.speed, that.speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(cores, speed);
|
||||||
int result = 1;
|
|
||||||
long temp;
|
|
||||||
temp = Double.doubleToLongBits(cores);
|
|
||||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
|
||||||
temp = Double.doubleToLongBits(speed);
|
|
||||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public String toString() {
|
||||||
if (this == obj)
|
return string().toString();
|
||||||
return true;
|
}
|
||||||
if (obj == null)
|
|
||||||
return false;
|
protected ToStringHelper string() {
|
||||||
if (getClass() != obj.getClass())
|
return Objects.toStringHelper("").omitNullValues().add("cores", cores).add("speed", speed);
|
||||||
return false;
|
|
||||||
Processor other = (Processor) obj;
|
|
||||||
if (Double.doubleToLongBits(cores) != Double.doubleToLongBits(other.cores))
|
|
||||||
return false;
|
|
||||||
if (Double.doubleToLongBits(speed) != Double.doubleToLongBits(other.speed))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -91,11 +91,22 @@ public class ComputeMetadataImpl extends ResourceMetadataImpl<ComputeType> imple
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(super.hashCode(), id);
|
return Objects.hashCode(super.hashCode(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper computeToStringPrefix() {
|
||||||
|
return Objects.toStringHelper("").omitNullValues().add("id", getId()).add("providerId", getProviderId())
|
||||||
|
.add("uri", getUri()).add("name", getName()).add("uri", getUri()).add("location", getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper addComputeToStringSuffix(ToStringHelper helper) {
|
||||||
|
if (getTags().size() > 0)
|
||||||
|
helper.add("tags", getTags());
|
||||||
|
if (getUserMetadata().size() > 0)
|
||||||
|
helper.add("userMetadata", getUserMetadata());
|
||||||
|
return helper;
|
||||||
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("").add("type", getType()).add("id", id).add("providerId", getProviderId()).add(
|
return addComputeToStringSuffix(computeToStringPrefix());
|
||||||
"name", getName()).add("location", getLocation()).add("uri", getUri()).add("tags", getTags()).add(
|
|
||||||
"userMetadata", getUserMetadata());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.ResourceMetadata;
|
import org.jclouds.domain.ResourceMetadata;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ComparisonChain;
|
import com.google.common.collect.ComparisonChain;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -111,14 +112,15 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
protected ToStringHelper string() {
|
||||||
return "[id=" + getId() + ", providerId=" + getProviderId() + ", name=" + getName() + ", processors="
|
ToStringHelper helper = computeToStringPrefix();
|
||||||
+ processors + ", ram=" + ram + ", volumes=" + volumes + ", hypervisor=" + hypervisor
|
helper.add("processors", processors).add("ram", ram);
|
||||||
+ ", supportsImage=" + supportsImage + ", tags=" + tags + "]";
|
if (volumes.size() > 0)
|
||||||
|
helper.add("volumes", volumes);
|
||||||
|
helper.add("hypervisor", hypervisor);
|
||||||
|
helper.add("supportsImage", supportsImage);
|
||||||
|
return addComputeToStringSuffix(helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,11 +123,11 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
// equals and toString from super are sufficient to establish identity equivalence
|
// equals and toString from super are sufficient to establish identity equivalence
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("").add("id", getId()).add("providerId", getProviderId()).add("name", getName())
|
ToStringHelper helper = computeToStringPrefix();
|
||||||
.add("os", getOperatingSystem()).add("description", getDescription()).add("version", getVersion()).add(
|
helper.add("os", getOperatingSystem()).add("description", getDescription()).add("version", getVersion())
|
||||||
"location", getLocation()).add("status", formatStatus(this)).add("loginUser",
|
.add("status", formatStatus(this))
|
||||||
((defaultCredentials != null) ? defaultCredentials.identity : null)).add("tags", getTags())
|
.add("loginUser", ((defaultCredentials != null) ? defaultCredentials.identity : null));
|
||||||
.add("userMetadata", getUserMetadata());
|
return addComputeToStringSuffix(helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
@ -193,12 +192,14 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
// equals and toString from super are sufficient to establish identity equivalence
|
// equals and toString from super are sufficient to establish identity equivalence
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("").add("id", getId()).add("providerId", getProviderId()).add("group", getGroup())
|
ToStringHelper helper = computeToStringPrefix();
|
||||||
.add("name", getName()).add("location", getLocation()).add("uri", getUri()).add("imageId", getImageId())
|
helper.add("group", getGroup()).add("imageId", getImageId()).add("os", getOperatingSystem())
|
||||||
.add("os", getOperatingSystem()).add("status", formatStatus(this)).add("loginPort", getLoginPort()).add(
|
.add("status", formatStatus(this)).add("loginPort", getLoginPort()).add("hostname", getHostname());
|
||||||
"hostname", getHostname()).add("privateAddresses", getPrivateAddresses()).add(
|
if (getPrivateAddresses().size() > 0)
|
||||||
"publicAddresses", getPublicAddresses()).add("hardware", getHardware()).add("loginUser",
|
helper.add("privateAddresses", getPrivateAddresses());
|
||||||
((credentials != null) ? credentials.identity : null)).add("tags", getTags()).add(
|
if (getPublicAddresses().size() > 0)
|
||||||
"userMetadata", getUserMetadata());
|
helper.add("publicAddresses", getPublicAddresses());
|
||||||
|
helper.add("hardware", getHardware()).add("loginUser", ((credentials != null) ? credentials.identity : null));
|
||||||
|
return addComputeToStringSuffix(helper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.domain.internal;
|
package org.jclouds.compute.domain.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
@ -26,6 +27,9 @@ import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -33,13 +37,13 @@ import org.jclouds.domain.Location;
|
||||||
public class TemplateImpl implements Template {
|
public class TemplateImpl implements Template {
|
||||||
|
|
||||||
private final Image image;
|
private final Image image;
|
||||||
private final Hardware size;
|
private final Hardware hardware;
|
||||||
private final Location location;
|
private final Location location;
|
||||||
private final TemplateOptions options;
|
private final TemplateOptions options;
|
||||||
|
|
||||||
public TemplateImpl(Image image, Hardware size, Location location, TemplateOptions options) {
|
public TemplateImpl(Image image, Hardware hardware, Location location, TemplateOptions options) {
|
||||||
this.image = checkNotNull(image, "image");
|
this.image = checkNotNull(image, "image");
|
||||||
this.size = checkNotNull(size, "size");
|
this.hardware = checkNotNull(hardware, "hardware");
|
||||||
this.location = checkNotNull(location, "location");
|
this.location = checkNotNull(location, "location");
|
||||||
this.options = checkNotNull(options, "options");
|
this.options = checkNotNull(options, "options");
|
||||||
}
|
}
|
||||||
|
@ -57,7 +61,7 @@ public class TemplateImpl implements Template {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Hardware getHardware() {
|
public Hardware getHardware() {
|
||||||
return size;
|
return hardware;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,52 +81,36 @@ public class TemplateImpl implements Template {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(Object o) {
|
||||||
final int prime = 31;
|
if (this == o)
|
||||||
int result = 1;
|
return true;
|
||||||
result = prime * result + ((image == null) ? 0 : image.hashCode());
|
if (o == null || getClass() != o.getClass())
|
||||||
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
return false;
|
||||||
result = prime * result + ((options == null) ? 0 : options.hashCode());
|
TemplateImpl that = TemplateImpl.class.cast(o);
|
||||||
result = prime * result + ((size == null) ? 0 : size.hashCode());
|
return equal(this.image, that.image) && equal(this.hardware, that.hardware)
|
||||||
return result;
|
&& equal(this.location, that.location) && equal(this.options, that.options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public int hashCode() {
|
||||||
if (this == obj)
|
return Objects.hashCode(image, hardware, location, options);
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
TemplateImpl other = (TemplateImpl) obj;
|
|
||||||
if (image == null) {
|
|
||||||
if (other.image != null)
|
|
||||||
return false;
|
|
||||||
} else if (!image.equals(other.image))
|
|
||||||
return false;
|
|
||||||
if (location == null) {
|
|
||||||
if (other.location != null)
|
|
||||||
return false;
|
|
||||||
} else if (!location.equals(other.location))
|
|
||||||
return false;
|
|
||||||
if (options == null) {
|
|
||||||
if (other.options != null)
|
|
||||||
return false;
|
|
||||||
} else if (!options.equals(other.options))
|
|
||||||
return false;
|
|
||||||
if (size == null) {
|
|
||||||
if (other.size != null)
|
|
||||||
return false;
|
|
||||||
} else if (!size.equals(other.size))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[location=" + location + ", image=" + image + ", size=" + size + ", options="
|
return string().toString();
|
||||||
+ options + "]";
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("image", image).add("hardware", hardware)
|
||||||
|
.add("location", location);
|
||||||
|
if (!options.equals(defaultOptions()))
|
||||||
|
helper.add("options", options);
|
||||||
|
return helper;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TemplateOptions defaultOptions() {
|
||||||
|
return TemplateOptions.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +118,7 @@ public class TemplateImpl implements Template {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Template clone() {
|
public Template clone() {
|
||||||
return new TemplateImpl(image, size, location, options.clone());
|
return new TemplateImpl(image, hardware, location, options.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.domain.internal;
|
package org.jclouds.compute.domain.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Volume;
|
import org.jclouds.compute.domain.Volume;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@ -30,13 +34,40 @@ public class VolumeImpl implements Volume {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Volume.Type type;
|
private final Volume.Type type;
|
||||||
private final @Nullable
|
@Nullable
|
||||||
Float size;
|
private final Float size;
|
||||||
private final @Nullable
|
@Nullable
|
||||||
String device;
|
private final String device;
|
||||||
private final boolean bootDevice;
|
private final boolean bootDevice;
|
||||||
private final boolean durable;
|
private final boolean durable;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
VolumeImpl that = VolumeImpl.class.cast(o);
|
||||||
|
return equal(this.id, that.id) && equal(this.getType(), that.getType()) && equal(this.size, that.size)
|
||||||
|
&& equal(this.device, that.device) && equal(this.bootDevice, that.bootDevice)
|
||||||
|
&& equal(this.durable, that.durable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(id, size, device, bootDevice, durable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper("").omitNullValues().add("id", id).add("type", getType()).add("size", size)
|
||||||
|
.add("device", device).add("bootDevice", bootDevice).add("durable", durable);
|
||||||
|
}
|
||||||
|
|
||||||
public VolumeImpl(@Nullable String id, Volume.Type type, @Nullable Float size, @Nullable String device,
|
public VolumeImpl(@Nullable String id, Volume.Type type, @Nullable Float size, @Nullable String device,
|
||||||
boolean bootDevice, boolean durable) {
|
boolean bootDevice, boolean durable) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -103,62 +134,5 @@ public class VolumeImpl implements Volume {
|
||||||
return bootDevice;
|
return bootDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "[id=" + getId() + ", type=" + type + ", size=" + size + ", device=" + device + ", durable=" + durable
|
|
||||||
+ ", isBootDevice=" + bootDevice + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + (bootDevice ? 1231 : 1237);
|
|
||||||
result = prime * result + ((device == null) ? 0 : device.hashCode());
|
|
||||||
result = prime * result + (durable ? 1231 : 1237);
|
|
||||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
|
||||||
result = prime * result + ((size == null) ? 0 : size.hashCode());
|
|
||||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
VolumeImpl other = (VolumeImpl) obj;
|
|
||||||
if (bootDevice != other.bootDevice)
|
|
||||||
return false;
|
|
||||||
if (device == null) {
|
|
||||||
if (other.device != null)
|
|
||||||
return false;
|
|
||||||
} else if (!device.equals(other.device))
|
|
||||||
return false;
|
|
||||||
if (durable != other.durable)
|
|
||||||
return false;
|
|
||||||
if (id == null) {
|
|
||||||
if (other.id != null)
|
|
||||||
return false;
|
|
||||||
} else if (!id.equals(other.id))
|
|
||||||
return false;
|
|
||||||
if (size == null) {
|
|
||||||
if (other.size != null)
|
|
||||||
return false;
|
|
||||||
} else if (!size.equals(other.size))
|
|
||||||
return false;
|
|
||||||
if (type == null) {
|
|
||||||
if (other.type != null)
|
|
||||||
return false;
|
|
||||||
} else if (!type.equals(other.type))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.domain.internal;
|
package org.jclouds.domain.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -28,6 +29,8 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
@ -46,6 +49,41 @@ public class LocationImpl implements Location, Serializable {
|
||||||
private final Set<String> iso3166Codes;
|
private final Set<String> iso3166Codes;
|
||||||
private final Map<String, Object> metadata;
|
private final Map<String, Object> metadata;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
LocationImpl that = LocationImpl.class.cast(o);
|
||||||
|
return equal(this.scope, that.scope) && equal(this.id, that.id) && equal(this.parent, that.parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(scope, id, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("scope", scope).add("id", id)
|
||||||
|
.add("description", description);
|
||||||
|
|
||||||
|
if (parent != null)
|
||||||
|
helper.add("parent", parent.getId());
|
||||||
|
|
||||||
|
if (iso3166Codes.size() > 0)
|
||||||
|
helper.add("iso3166Codes", iso3166Codes);
|
||||||
|
if (metadata.size() > 0)
|
||||||
|
helper.add("metadata", metadata);
|
||||||
|
return helper;
|
||||||
|
}
|
||||||
|
|
||||||
public LocationImpl(LocationScope scope, String id, String description, @Nullable Location parent,
|
public LocationImpl(LocationScope scope, String id, String description, @Nullable Location parent,
|
||||||
Iterable<String> iso3166Codes, Map<String, Object> metadata) {
|
Iterable<String> iso3166Codes, Map<String, Object> metadata) {
|
||||||
this.scope = checkNotNull(scope, "scope");
|
this.scope = checkNotNull(scope, "scope");
|
||||||
|
@ -104,66 +142,4 @@ public class LocationImpl implements Location, Serializable {
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
|
||||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
|
||||||
result = prime * result + ((iso3166Codes == null) ? 0 : iso3166Codes.hashCode());
|
|
||||||
result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
|
|
||||||
result = prime * result + ((parent == null) ? 0 : parent.hashCode());
|
|
||||||
result = prime * result + ((scope == null) ? 0 : scope.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
LocationImpl other = (LocationImpl) obj;
|
|
||||||
if (description == null) {
|
|
||||||
if (other.description != null)
|
|
||||||
return false;
|
|
||||||
} else if (!description.equals(other.description))
|
|
||||||
return false;
|
|
||||||
if (id == null) {
|
|
||||||
if (other.id != null)
|
|
||||||
return false;
|
|
||||||
} else if (!id.equals(other.id))
|
|
||||||
return false;
|
|
||||||
if (iso3166Codes == null) {
|
|
||||||
if (other.iso3166Codes != null)
|
|
||||||
return false;
|
|
||||||
} else if (!iso3166Codes.equals(other.iso3166Codes))
|
|
||||||
return false;
|
|
||||||
if (metadata == null) {
|
|
||||||
if (other.metadata != null)
|
|
||||||
return false;
|
|
||||||
} else if (!metadata.equals(other.metadata))
|
|
||||||
return false;
|
|
||||||
if (parent == null) {
|
|
||||||
if (other.parent != null)
|
|
||||||
return false;
|
|
||||||
} else if (!parent.equals(other.parent))
|
|
||||||
return false;
|
|
||||||
if (scope == null) {
|
|
||||||
if (other.scope != null)
|
|
||||||
return false;
|
|
||||||
} else if (!scope.equals(other.scope))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "[id=" + id + ", scope=" + scope + ", description=" + description + ", parent="
|
|
||||||
+ ((parent == null) ? null : parent.getId()) + ", iso3166Codes=" + iso3166Codes + ", metadata="
|
|
||||||
+ metadata + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -134,8 +134,8 @@ public abstract class ResourceMetadataImpl<T extends Enum<T>> implements Resourc
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("").add("type", getType()).add("providerId", providerId).add("name", name).add(
|
return Objects.toStringHelper("").omitNullValues().add("type", getType()).add("providerId", providerId)
|
||||||
"location", location).add("uri", uri).add("userMetadata", userMetadata);
|
.add("name", name).add("location", location).add("uri", uri).add("userMetadata", userMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue