Use Objects.hashCode()
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / repo / api / SourceIdentifier.java
index f46ed3f426553be6f37a5a94e72b7d96b965c24c..43879624c99d9da581073e72d5afffa13296e3af 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.model.repo.api;
 import com.google.common.annotations.Beta;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import java.util.Objects;
 import java.util.regex.Pattern;
 import org.opendaylight.yangtools.concepts.Identifier;
 import org.opendaylight.yangtools.concepts.Immutable;
@@ -56,12 +57,22 @@ public final class SourceIdentifier implements Identifier, Immutable {
      */
     public static final Pattern REVISION_PATTERN = Pattern.compile("\\d\\d\\d\\d-\\d\\d-\\d\\d");
 
-
     private static final ObjectCache CACHE = ObjectCacheFactory.getObjectCache(SourceIdentifier.class);
     private static final long serialVersionUID = 1L;
     private final String revision;
     private final String name;
 
+    /**
+     *
+     * Creates new YANG Schema source identifier for sources without revision.
+     * {@link SourceIdentifier#NOT_PRESENT_FORMATTED_REVISION} as default revision.
+     *
+     * @param name Name of schema
+     */
+    public SourceIdentifier(final String name) {
+        this(name, NOT_PRESENT_FORMATTED_REVISION);
+    }
+
     /**
      * Creates new YANG Schema source identifier.
      *
@@ -93,17 +104,6 @@ public final class SourceIdentifier implements Identifier, Immutable {
         return CACHE.getReference(this);
     }
 
-    /**
-     *
-     * Creates new YANG Schema source identifier for sources without revision.
-     * {@link SourceIdentifier#NOT_PRESENT_FORMATTED_REVISION} as default revision.
-     *
-     * @param name Name of schema
-     */
-    public SourceIdentifier(final String name) {
-        this(name, NOT_PRESENT_FORMATTED_REVISION);
-    }
-
     /**
      * Returns model name
      *
@@ -126,8 +126,8 @@ public final class SourceIdentifier implements Identifier, Immutable {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result + ((revision == null) ? 0 : revision.hashCode());
+        result = prime * result + Objects.hashCode(name);
+        result = prime * result + Objects.hashCode(revision);
         return result;
     }
 
@@ -200,7 +200,7 @@ public final class SourceIdentifier implements Identifier, Immutable {
      *
      * @return Filename for this source identifier.
      */
-    public static final String toYangFileName(final String moduleName, final Optional<String> revision) {
+    public static String toYangFileName(final String moduleName, final Optional<String> revision) {
         StringBuilder filename = new StringBuilder(moduleName);
         if (revision.isPresent()) {
             filename.append('@');