Fix for Bug 134: added restriction check to classes wrapping int and uint values.
[yangtools.git] / code-generator / binding-generator-util / src / main / java / org / opendaylight / yangtools / binding / generator / util / AbstractBaseType.java
index 5707c78053b3635b8252554cc8e32f59a2b701cb..735c888a0eb172f314f841ddaa93d4a42859b192 100644 (file)
@@ -55,6 +55,12 @@ public class AbstractBaseType implements Type {
      *            string with the name for this <code>Type</code>
      */
     protected AbstractBaseType(String pkName, String name) {
+        if (pkName == null) {
+            throw new IllegalArgumentException("Package Name for Generated Type cannot be null!");
+        }
+        if (name == null) {
+            throw new IllegalArgumentException("Name of Generated Type cannot be null!");
+        }
         this.packageName = pkName;
         this.name = name;
     }
@@ -70,23 +76,30 @@ public class AbstractBaseType implements Type {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (false ==(obj instanceof Type)) {
             return false;
+        }
         Type other = (Type) obj;
         if (name == null) {
-            if (other.getName() != null)
+            if (other.getName() != null) {
                 return false;
-        } else if (!name.equals(other.getName()))
+            }
+        } else if (!name.equals(other.getName())) {
             return false;
+        }
         if (packageName == null) {
-            if (other.getPackageName() != null)
+            if (other.getPackageName() != null) {
                 return false;
-        } else if (!packageName.equals(other.getPackageName()))
+            }
+        } else if (!packageName.equals(other.getPackageName())) {
             return false;
+        }
         return true;
     }