if (columnComparator != null) {
Collections.sort(properties, columnComparator);
}
for (Property property : properties) {
String name = property.getEscapedName();
ColumnMetadata metadata = (ColumnMetadata) property.getData().get("COLUMN");
StringBuilder columnMeta = new StringBuilder();
columnMeta.append("ColumnMetadata");
columnMeta.append(".named(\"" + metadata.getName() + "\")");
columnMeta.append(".withIndex(" + metadata.getIndex() + ")");
String type = String.valueOf(metadata.getJdbcType());
if (typeConstants.containsKey(metadata.getJdbcType())) {
type = "Types." + typeConstants.get(metadata.getJdbcType());
}
columnMeta.append(".ofType(" + type + ")");
if (metadata.hasSize()) {
columnMeta.append(".withSize(" + metadata.getSize() + ")");
}
if (metadata.getDigits() > 0) {
columnMeta.append(".withDigits(" + metadata.getDigits() + ")");
}
if (!metadata.isNullable()) {
columnMeta.append(".notNull()");
}
writer.line("addMetadata(", name, ", ", columnMeta.toString(), ");");
}
writer.end();