toString tidies

This commit is contained in:
Adrian Cole 2012-03-23 13:09:01 -07:00
parent cb370ab26d
commit ed1864e810
3 changed files with 39 additions and 8 deletions

View File

@ -18,7 +18,6 @@
*/
package org.jclouds.openstack.nova.v1_1.domain;
import static com.google.common.base.Objects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
@ -562,15 +561,11 @@ public class Server extends Resource {
// hashCode/equals from super is ok
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return toStringHelper("").add("id", id).add("uuid", uuid).add("name", name).add("tenantId", tenantId).add(
return super.string().add("uuid", uuid).add("tenantId", tenantId).add(
"userId", userId).add("hostId", getHostId()).add("updated", updated).add("created", created).add(
"accessIPv4", getAccessIPv4()).add("accessIPv6", getAccessIPv6()).add("status", status).add(
"configDrive", getConfigDrive()).add("image", image).add("flavor", flavor).add("metadata", metadata)
.add("links", links).add("addresses", getAddresses()).add("adminPass", adminPass);
.add("addresses", getAddresses()).add("adminPass", adminPass);
}
}

View File

@ -28,6 +28,7 @@ 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;
/**
@ -148,7 +149,11 @@ public class Resource implements Comparable<Resource> {
@Override
public String toString() {
return toStringHelper("").add("id", getId()).add("name", name).add("links", links).toString();
return string().toString();
}
protected ToStringHelper string() {
return toStringHelper("").add("id", getId()).add("name", name).add("links", links);
}
@Override

View File

@ -18,13 +18,17 @@
*/
package org.jclouds.rest.suppliers;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Objects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import javax.inject.Inject;
import com.google.common.base.Objects;
import com.google.common.base.Supplier;
import com.google.common.base.Objects.ToStringHelper;
public class URIFromStringSupplier implements Supplier<URI> {
@ -40,4 +44,31 @@ public class URIFromStringSupplier implements Supplier<URI> {
return endpoint;
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object instanceof URIFromStringSupplier) {
final URIFromStringSupplier other = URIFromStringSupplier.class.cast(object);
return equal(endpoint, other.endpoint);
} else {
return false;
}
}
@Override
public int hashCode() {
return Objects.hashCode(endpoint);
}
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return toStringHelper("").add("endpoint", endpoint);
}
}