Skip to content

Commit

Permalink
Update "@generated" annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
safris committed Jun 17, 2023
1 parent 028d1ae commit 59b2b0d
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions jsql/src/main/java/org/jaxdb/jsql/generator/SchemaManifest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.jaxdb.jsql.generator.GeneratorUtil.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -40,13 +40,12 @@
import org.libj.lang.Identifiers;

class SchemaManifest {
private static final String GENERATED_VALUE = "Autogenerated by JAX-DB Compiler (" + Generator.class.getPackage().getImplementationVersion() + ")";
private static final String GENERATED_DATE = LocalDate.now().toString();
private static final String GENERATED = "(value=\"" + Generator.class.getName() + "\", date=\"" + LocalDateTime.now().toString() + "\")";
private static final String HEADER_COMMENT;

static {
final StringBuilder out = new StringBuilder();
out.append("/* ").append(GENERATED_VALUE).append('\n');
out.append("/* ").append("Autogenerated by JAX-DB Compiler (").append(Generator.class.getPackage().getImplementationVersion()).append(")\n");
out.append(" * THIS FILE SHOULD NOT BE EDITED */\n");
HEADER_COMMENT = out.toString();
}
Expand Down Expand Up @@ -90,22 +89,24 @@ String generate(final DDLx ddlx) throws GeneratorExecutionException {
out.append("package ").append(packageName).append(";\n\n");
out.append(getDoc(ddlx.getNormalizedSchema(), 0, '\0', '\n', "Schema", schemaClassSimpleName));
out.append('@').append(SuppressWarnings.class.getName()).append("(\"all\")\n");
out.append('@').append(Generated.class.getName()).append("(value=\"").append(GENERATED_VALUE).append("\", date=\"").append(GENERATED_DATE).append("\")\n");
out.append('@').append(Generated.class.getName()).append(GENERATED).append('\n');

out.append("public class ").append(schemaClassSimpleName).append(" extends ").append(Schema.class.getCanonicalName()).append(" {");

final StringBuilder cachedTables = new StringBuilder();
final Collection<TableMeta> tableMetas = tableNameToTableMeta.values();
if (tableMetas.size() > 0) {
final int noTables = tableMetas.size();
if (noTables > 0) {
for (final TableMeta tableMeta : tableMetas) { // [C]
tableMeta.init();
if (!tableMeta.isAbstract)
cachedTables.append(tableMeta.classCase).append("(), ");
}
}

if (cachedTables.length() > 0)
cachedTables.setLength(cachedTables.length() - 2);
final int len = cachedTables.length();
if (len > 0)
cachedTables.setLength(len - 2);

final BindingList<$Column> templates = ddlx.getNormalizedSchema().getTemplate();
if (templates != null) {
Expand All @@ -123,7 +124,7 @@ String generate(final DDLx ddlx) throws GeneratorExecutionException {
final ArrayList<TableMeta> sortedTables = new ArrayList<>();

// First create the abstract entities
if (tableMetas.size() > 0) {
if (noTables > 0) {
for (final TableMeta tableMeta : tableMetas) // [C]
if (tableMeta.isAbstract)
out.append(tableMeta.makeTable()).append('\n');
Expand All @@ -137,14 +138,16 @@ String generate(final DDLx ddlx) throws GeneratorExecutionException {
}

sortedTables.sort(Generator.tableMetaComparator);
final int noSortedTables = sortedTables.size();

out.append("\n private static final ").append(String.class.getName()).append("[] names = {");
for (int i = 0, i$ = sortedTables.size(); i < i$; ++i) // [RA]
for (int i = 0; i < noSortedTables; ++i) // [RA]
out.append('"').append(sortedTables.get(i).tableName).append("\", ");

out.setCharAt(out.length() - 2, '}');
out.setCharAt(out.length() - 1, ';');
out.append("\n private final ").append(type.Table$.class.getCanonicalName()).append("[] tables = {");
for (int i = 0, i$ = sortedTables.size(); i < i$; ++i) // [RA]
for (int i = 0; i < noSortedTables; ++i) // [RA]
out.append(sortedTables.get(i).singletonInstanceName).append(", ");

out.setCharAt(out.length() - 2, '}');
Expand Down

0 comments on commit 59b2b0d

Please sign in to comment.