From c43d89d6d8146b1265e24e207619641cbd2c0393 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Fri, 11 May 2012 09:54:56 -0700 Subject: [PATCH] Use Objects.equal in ContentMetadataBuilder.equals Inspired by a discussion with @aledsage. --- .../jclouds/io/ContentMetadataBuilder.java | 35 ++++--------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/core/src/main/java/org/jclouds/io/ContentMetadataBuilder.java b/core/src/main/java/org/jclouds/io/ContentMetadataBuilder.java index 04980c475e..11694871c1 100644 --- a/core/src/main/java/org/jclouds/io/ContentMetadataBuilder.java +++ b/core/src/main/java/org/jclouds/io/ContentMetadataBuilder.java @@ -30,6 +30,7 @@ import org.jclouds.crypto.CryptoStreams; import org.jclouds.io.payloads.BaseImmutableContentMetadata; import org.jclouds.javax.annotation.Nullable; +import com.google.common.base.Objects; import com.google.common.base.Predicate; import com.google.common.collect.Multimap; @@ -145,34 +146,12 @@ public class ContentMetadataBuilder implements Serializable { if (getClass() != obj.getClass()) return false; ContentMetadataBuilder other = (ContentMetadataBuilder) obj; - if (contentDisposition == null) { - if (other.contentDisposition != null) - return false; - } else if (!contentDisposition.equals(other.contentDisposition)) - return false; - if (contentEncoding == null) { - if (other.contentEncoding != null) - return false; - } else if (!contentEncoding.equals(other.contentEncoding)) - return false; - if (contentLanguage == null) { - if (other.contentLanguage != null) - return false; - } else if (!contentLanguage.equals(other.contentLanguage)) - return false; - if (contentLength == null) { - if (other.contentLength != null) - return false; - } else if (!contentLength.equals(other.contentLength)) - return false; - if (!Arrays.equals(contentMD5, other.contentMD5)) - return false; - if (contentType == null) { - if (other.contentType != null) - return false; - } else if (!contentType.equals(other.contentType)) - return false; - return true; + return Objects.equal(contentDisposition, other.contentDisposition) && + Objects.equal(contentEncoding, other.contentEncoding) && + Objects.equal(contentLanguage, other.contentLanguage) && + Objects.equal(contentLength, other.contentLength) && + Arrays.equals(contentMD5, other.contentMD5) && + Objects.equal(contentType, other.contentType); } @Override