1 23 24 package org.continuent.sequoia.controller.sql.schema; 25 26 import java.io.Serializable ; 27 import java.sql.Types ; 28 29 39 public class DatabaseColumn implements Serializable 40 { 41 private static final long serialVersionUID = 1118853825798791836L; 42 43 44 private String name; 45 46 50 private boolean isUnique; 51 52 53 private int type; 54 55 62 public DatabaseColumn(String name, boolean isUnique) 63 { 64 this(name, isUnique, Types.NULL); 65 } 66 67 76 public DatabaseColumn(String name, boolean isUnique, int type) 77 { 78 if (name == null) 79 throw new IllegalArgumentException ( 80 "Illegal null column name in DatabaseColumn constructor"); 81 82 this.name = name; 83 this.isUnique = isUnique; 84 this.type = type; 85 } 86 87 92 public String getName() 93 { 94 return name; 95 } 96 97 104 public int getType() 105 { 106 return type; 107 } 108 109 116 public boolean isUnique() 117 { 118 return isUnique; 119 } 120 121 126 public final void setType(int type) 127 { 128 this.type = type; 129 } 130 131 137 public void setIsUnique(boolean bool) 138 { 139 isUnique = bool; 140 } 141 142 149 public boolean equals(Object other) 150 { 151 if ((other == null) || !(other instanceof DatabaseColumn)) 152 return false; 153 154 DatabaseColumn c = (DatabaseColumn) other; 155 return (isUnique == c.isUnique()) && name.equals(c.getName()) 156 && (type == c.getType()); 157 } 158 159 166 public boolean equalsIgnoreType(Object other) 167 { 168 if ((other == null) || !(other instanceof DatabaseColumn)) 169 return false; 170 171 DatabaseColumn c = (DatabaseColumn) other; 172 return (isUnique == c.isUnique()) && name.equals(c.getName()); 173 } 174 175 178 public String toString() 179 { 180 return name; 181 } 182 } 183 | Popular Tags |