View Javadoc

1   /*
2    * joey-gen and its relative products are published under the terms
3    * of the Apache Software License.
4    * 
5    * Created on 2004/08/15 18:00:19
6    */
7   package org.asyrinx.joey.gen.command.rdb;
8   
9   import org.apache.commons.lang.StringUtils;
10  import org.asyrinx.joey.gen.model.rdb.Column;
11  import org.asyrinx.joey.gen.model.rdb.ColumnType;
12  
13  /***
14   * @author akima
15   */
16  public class CheckColumnType extends RdbCommand {
17  
18      public void visit(Column column) {
19          if (StringUtils.isEmpty(column.getType()))
20              addError(column, "column requires type");
21          final ColumnType type = ColumnType.get(column.getType());
22          if (type == null)
23              addError(column, "type '" + column.getType() + "' not found");
24          if (type.isRequiredSize() && column.getSizeAsInt() < 1)
25              addError(column, "type '" + type.getName() + "' requires size");
26      }
27  
28  }