return list;
}
private StatementBuilder generateColumn(Set<String> imports, ColumnInspector col,
boolean trimStrings) {
StatementBuilder sb = new StatementBuilder();
Class<?> clazz = col.clazz;
String column = ModelUtils.convertColumnToFieldName(col.name.toLowerCase());
sb.append('\t');
if (clazz == null) {
// unsupported type
clazz = Object.class;
sb.append("// unsupported type " + col.type);
} else {
// @JQColumn
imports.add(clazz.getCanonicalName());
sb.append('@').append(JQColumn.class.getSimpleName());
// JQColumn annotation parameters
AnnotationBuilder ap = new AnnotationBuilder();
// JQColumn.name
if (!col.name.equalsIgnoreCase(column)) {
ap.addParameter("name", col.name);
}
// JQColumn.primaryKey
// composite primary keys are annotated on the table
if (col.isPrimaryKey && primaryKeys.size() == 1) {
ap.addParameter("primaryKey=true");
}
// JQColumn.maxLength
if ((clazz == String.class) && (col.size > 0)
&& (col.size < Integer.MAX_VALUE)) {
ap.addParameter("maxLength", col.size);
// JQColumn.trimStrings
if (trimStrings) {
ap.addParameter("trimString=true");
}
} else {
// JQColumn.AutoIncrement
if (col.isAutoIncrement) {
ap.addParameter("autoIncrement=true");
}
}
// JQColumn.allowNull
if (!col.allowNull) {
ap.addParameter("allowNull=false");
}
// JQColumn.defaultValue
if (!isNullOrEmpty(col.defaultValue)) {
ap.addParameter("defaultValue=\"" + col.defaultValue + "\"");
}
// add leading and trailing ()
if (ap.length() > 0) {
ap.insert(0, '(');
ap.append(')');
}
sb.append(ap);
}
sb.append(eol);
// variable declaration
sb.append("\t" + "public ");
sb.append(clazz.getSimpleName());
sb.append(' ');
sb.append(column);
sb.append(';');
sb.append(eol).append(eol);
return sb;
}