Add some unit testing of the CfbSchema.
[cfb.git] / prod / net / jaekl / cfb / db / Column.java
index bd06570dd2bfdfbe8560ca47f5ec60d0efd857a5..8fc723ded7b00521bbb8fd103aa9c054437e961e 100644 (file)
@@ -1,8 +1,12 @@
 package net.jaekl.cfb.db;
 
+import net.jaekl.cfb.util.Util;
+
+// Copyright (C) 2015 Christian Jaekl
+
 public class Column {
        public enum Type {
-               CHAR, INTEGER, TIMESTAMP, TIMESTAMPTZ, VARCHAR 
+               CHAR, INTEGER, TIMESTAMPTZ, VARCHAR 
        };
        public enum Null {
                NOT_NULL, NULL
@@ -43,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;
+       }
 }