Merge "Removed unused dependency."
[yangtools.git] / yang / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / QNameModule.java
index 452b2fa99e78965f5949a83801f738db137be34b..def8da86cbeeec77689b50f44c0493456a172b9f 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.common;
 
+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;
@@ -78,8 +80,7 @@ public final class QNameModule implements Immutable, Serializable {
 
     /**
      * Returns the namespace of the module which is specified as argument of
-     * YANG {@link Module <b><font color="#00FF00">namespace</font></b>}
-     * keyword.
+     * YANG Module <b><font color="#00FF00">namespace</font></b> keyword.
      *
      * @return URI format of the namespace of the module
      */
@@ -91,8 +92,7 @@ public final class QNameModule implements Immutable, Serializable {
      * Returns the revision date for the module.
      *
      * @return date of the module revision which is specified as argument of
-     *         YANG {@link Module <b><font color="#339900">revison</font></b>}
-     *         keyword
+     *         YANG Module <b><font color="#339900">revison</font></b> keyword
      */
     public Date getRevision() {
         return revision;
@@ -115,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;
@@ -158,9 +150,14 @@ 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;
     }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this).omitNullValues().add("ns", getNamespace()).add("rev", getFormattedRevision()).toString();
+    }
 }