Use Objects.hashCode()
[yangtools.git] / yang / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / QNameModule.java
index 628af0c4ebfe964116ae6130ed4b0dcc57bff75e..1ddd092db52b2e6d99221de60f6b6c4f3502c5f8 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.common;
 
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
 import java.io.Serializable;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Date;
+import java.util.Objects;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.objcache.ObjectCache;
 import org.opendaylight.yangtools.objcache.ObjectCacheFactory;
@@ -100,8 +101,8 @@ public final class QNameModule implements Immutable, Serializable {
     @Override
     public int hashCode() {
         final int prime = 31;
-        int result = (namespace == null) ? 0 : namespace.hashCode();
-        result = prime * result + ((revision == null) ? 0 : revision.hashCode());
+        int result = Objects.hashCode(namespace);
+        result = prime * result + Objects.hashCode(revision);
         return result;
     }
 
@@ -114,18 +115,10 @@ public final class QNameModule implements Immutable, Serializable {
             return false;
         }
         final QNameModule other = (QNameModule) obj;
-        if (revision == null) {
-            if (other.revision != null) {
-                return false;
-            }
-        } else if (!revision.equals(other.revision)) {
+        if (!Objects.equals(revision, other.revision)) {
             return false;
         }
-        if (namespace == null) {
-            if (other.namespace != null) {
-                return false;
-            }
-        } else if (!namespace.equals(other.namespace)) {
+        if (!Objects.equals(namespace, other.namespace)) {
             return false;
         }
         return true;
@@ -157,7 +150,7 @@ public final class QNameModule implements Immutable, Serializable {
         try {
             compositeURI = new URI(namespace.getScheme(), namespace.getUserInfo(), namespace.getHost(),
                     namespace.getPort(), namespace.getPath(), query, namespace.getFragment());
-        } catch (URISyntaxException e) {
+        } catch (final URISyntaxException e) {
             LOG.error("", e);
         }
         return compositeURI;
@@ -165,6 +158,6 @@ public final class QNameModule implements Immutable, Serializable {
 
     @Override
     public String toString() {
-        return Objects.toStringHelper(this).omitNullValues().add("ns", getNamespace()).add("rev", getFormattedRevision()).toString();
+        return MoreObjects.toStringHelper(this).omitNullValues().add("ns", getNamespace()).add("rev", getFormattedRevision()).toString();
     }
 }