BUG-731: eliminate magic constants 07/6807/2
authorRobert Varga <rovarga@cisco.com>
Thu, 8 May 2014 06:54:35 +0000 (08:54 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Sat, 10 May 2014 17:56:04 +0000 (17:56 +0000)
We can use a boxed Boolean, whose hashCode() does precisely the same
thing. So let's keep magic down to a minimum.

Change-Id: Ie855a1508cc2c6b19d744dbdab04ed8794fdcd95
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java

index f05c2b26dafb859556e768951f9560abcd90d517..c277d3b8cbb3636c4e93c652ecf6c84a1283feac 100644 (file)
@@ -14,14 +14,11 @@ import java.util.List;
 import org.opendaylight.yangtools.yang.common.QName;
 
 /**
- * 
+ *
  * Represents unique path to the every node inside the module.
- * 
+ *
  */
 public class SchemaPath {
-    private final int hashBooleanTrue = 1231;
-    private final int hashBooleanFalse = 1237;
-
     /**
      * List of QName instances which represents complete path to the node.
      */
@@ -31,11 +28,11 @@ public class SchemaPath {
      * Boolean value which represents type of schema path (relative or
      * absolute).
      */
-    private final boolean absolute;
+    private final Boolean absolute;
 
     /**
      * Constructs new instance of this class with the concrete path.
-     * 
+     *
      * @param path
      *            list of QName instances which specifies exact path to the
      *            module node
@@ -43,14 +40,14 @@ public class SchemaPath {
      *            boolean value which specifies if the path is absolute or
      *            relative
      */
-    public SchemaPath(final List<QName> path, boolean absolute) {
+    public SchemaPath(final List<QName> path, final boolean absolute) {
         this.path = Collections.unmodifiableList(new ArrayList<QName>(path));
         this.absolute = absolute;
     }
 
     /**
      * Returns the complete path to schema node.
-     * 
+     *
      * @return list of <code>QName</code> instances which represents complete
      *         path to schema node
      */
@@ -60,7 +57,7 @@ public class SchemaPath {
 
     /**
      * Describes whether schema path is|isn't absolute.
-     * 
+     *
      * @return boolean value which is <code>true</code> if schema path is
      *         absolute.
      */
@@ -72,13 +69,13 @@ public class SchemaPath {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + (absolute ? hashBooleanTrue : hashBooleanFalse);
+        result = prime * result + absolute.hashCode();
         result = prime * result + ((path == null) ? 0 : path.hashCode());
         return result;
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }