1 24 package org.riotfamily.revolt.definition; 25 26 30 public class Column extends Identifier implements Cloneable { 31 32 private String type; 33 34 private int length; 35 36 private boolean lengthSet; 37 38 private String defaultValue; 39 40 private boolean defaultValueSet; 41 42 private boolean notNull; 43 44 private boolean notNullSet; 45 46 private boolean primaryKey; 47 48 private boolean primaryKeySet; 49 50 private boolean autoIncrement; 51 52 private boolean autoIncrementSet; 53 54 public Column() { 55 } 56 57 public Column(String name) { 58 super(name); 59 } 60 61 public Column(String name, String type) { 62 super(name); 63 this.type = type; 64 } 65 66 public Column(String name, String type, int length) { 67 this(name, type); 68 setLength(length); 69 } 70 71 public boolean isAutoIncrement() { 72 return autoIncrement; 73 } 74 75 public void setAutoIncrement(boolean autoIncrement) { 76 this.autoIncrement = autoIncrement; 77 autoIncrementSet = true; 78 } 79 80 public boolean isAutoIncrementSet() { 81 return this.autoIncrementSet; 82 } 83 84 public String getDefaultValue() { 85 return this.defaultValue; 86 } 87 88 public void setDefaultValue(String defaultValue) { 89 this.defaultValue = defaultValue; 90 defaultValueSet = true; 91 } 92 93 public boolean isDefaultValueSet() { 94 return this.defaultValueSet; 95 } 96 97 public int getLength() { 98 return this.length; 99 } 100 101 public void setLength(int length) { 102 this.length = length; 103 lengthSet = true; 104 } 105 106 public boolean isLengthSet() { 107 return this.lengthSet; 108 } 109 110 public boolean isNotNullSet() { 111 return notNullSet; 112 } 113 114 public boolean isNotNull() { 115 return notNull; 116 } 117 118 public void setNotNull(boolean notNull) { 119 this.notNull = notNull; 120 notNullSet = true; 121 } 122 123 public boolean isPrimaryKeySet() { 124 return primaryKeySet; 125 } 126 127 public boolean isPrimaryKey() { 128 return primaryKey; 129 } 130 131 public void setPrimaryKey(boolean primaryKey) { 132 this.primaryKey = primaryKey; 133 primaryKeySet = true; 134 } 135 136 public String getType() { 137 return this.type; 138 } 139 140 public void setType(String type) { 141 this.type = type; 142 } 143 144 public Column copy() { 145 try { 146 return (Column) clone(); 147 } 148 catch (CloneNotSupportedException e) { 149 throw new RuntimeException (e); 150 } 151 } 152 153 public void merge(Column column) { 154 if (column.isDefaultValueSet()) { 155 setDefaultValue(column.getDefaultValue()); 156 } 157 if (column.isNotNullSet()) { 158 setNotNull(column.isNotNull()); 159 } 160 if (column.getType() != null) { 161 setType(column.getType()); 162 } 163 if (column.isLengthSet()) { 164 setLength(column.getLength()); 165 } 166 if (column.isAutoIncrementSet()) { 167 setAutoIncrement(column.isAutoIncrement()); 168 } 169 } 170 } 171 | Popular Tags |