Add some unit testing of the CfbSchema.
[cfb.git] / prod / net / jaekl / cfb / db / Column.java
index db748b2a0afd083c32d083d1d01a7116153ce518..8fc723ded7b00521bbb8fd103aa9c054437e961e 100644 (file)
@@ -1,5 +1,7 @@
 package net.jaekl.cfb.db;
 
+import net.jaekl.cfb.util.Util;
+
 // Copyright (C) 2015 Christian Jaekl
 
 public class Column {
@@ -45,4 +47,40 @@ public class Column {
                
                return new Column(name, type, width.intValue(), canBeNull);
        }
+       
+       @Override 
+       public boolean equals(Object obj) 
+       {
+               if (null == obj) {
+                       return false;
+               }
+               if (! (obj instanceof Column)) {
+                       return false;
+               }
+               Column other = (Column)obj;
+
+               if (! Util.objsAreEqual(this.getName(), other.getName())) {
+                       return false;
+               }
+               if (! Util.objsAreEqual(this.getType(), other.getType())) {
+                       return false;
+               }
+               if (this.getWidth() != other.getWidth()) {
+                       return false;
+               }
+               if (! Util.objsAreEqual(this.getNull(), other.getNull())) {
+                       return false;
+               }
+               
+               return true;
+       }
+       
+       @Override
+       public int hashCode() {
+               int code = Util.objHashCode(getName())
+                                ^ Util.objHashCode(getType())
+                                ^ getWidth()
+                                ^ Util.objHashCode(getNull());
+               return code;
+       }
 }