diff --git a/core/src/main/java/org/jclouds/domain/internal/ResourceMetadataImpl.java b/core/src/main/java/org/jclouds/domain/internal/ResourceMetadataImpl.java index 2816abfaf6..e5258faecd 100644 --- a/core/src/main/java/org/jclouds/domain/internal/ResourceMetadataImpl.java +++ b/core/src/main/java/org/jclouds/domain/internal/ResourceMetadataImpl.java @@ -20,6 +20,8 @@ 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.collect.ComparisonChain.start; +import static com.google.common.collect.Ordering.natural; import java.net.URI; import java.util.Map; @@ -62,10 +64,10 @@ public abstract class ResourceMetadataImpl> implements Resourc * {@inheritDoc} */ @Override - public int compareTo(ResourceMetadata o) { - if (getName() == null) - return -1; - return (this == o) ? 0 : getName().compareTo(o.getName()); + public int compareTo(ResourceMetadata that) { + return start() + .compare(this.getName(), that.getName(), natural().nullsLast()) + .result(); } /**