use of org.jooq.meta.CatalogDefinition in project jOOQ by jOOQ.
the class JavaGenerator method printClassAnnotations.
protected void printClassAnnotations(JavaWriter out, Definition definition, Mode mode) {
if (generateGeneratedAnnotation()) {
SchemaDefinition schema = definition.getSchema();
CatalogDefinition catalog = definition.getCatalog();
// [#7581] The concrete annotation type depends on the JDK, with
// javax.annotation.Generated being deprecated in JDK 9
GeneratedAnnotationType type = generateGeneratedAnnotationType();
if (type == null)
type = GeneratedAnnotationType.DETECT_FROM_JDK;
String generated;
switch(type) {
case DETECT_FROM_JDK:
try {
// Seems more reliable than tampering with java.version
Reflect.onClass("java.util.Optional").call("of", new Object()).call("stream");
generated = "javax.annotation.processing.Generated";
} catch (ReflectException e) {
generated = "javax.annotation.Generated";
}
break;
case JAVAX_ANNOTATION_GENERATED:
generated = "javax.annotation.Generated";
break;
case JAVAX_ANNOTATION_PROCESSING_GENERATED:
generated = "javax.annotation.processing.Generated";
break;
default:
throw new IllegalStateException("Unsupported type: " + type);
}
out.println("@%s(", out.ref(generated));
if (useSchemaVersionProvider() || useCatalogVersionProvider()) {
boolean hasCatalogVersion = !StringUtils.isBlank(catalogVersions.get(catalog));
boolean hasSchemaVersion = !StringUtils.isBlank(schemaVersions.get(schema));
if (scala)
out.println("value = %s(", out.ref("scala.Array"));
else if (kotlin)
out.println("value = [");
else
out.println("value = {");
out.println("\"https://www.jooq.org\",");
out.println("\"jOOQ version:%s\"%s", Constants.VERSION, (hasCatalogVersion || hasSchemaVersion ? "," : ""));
if (hasCatalogVersion)
out.println("\"catalog version:%s\"%s", escapeString(catalogVersions.get(catalog)), (hasSchemaVersion ? "," : ""));
if (hasSchemaVersion)
out.println("\"schema version:%s\"", escapeString(schemaVersions.get(schema)));
if (scala)
out.println("),");
else if (kotlin)
out.println("],");
else
out.println("},");
if (generateGeneratedAnnotationDate())
out.println("date = \"" + isoDate + "\",");
out.println("comments = \"This class is generated by jOOQ\"");
} else {
if (scala)
out.println("value = %s(", out.ref("scala.Array"));
else if (kotlin)
out.println("value = [");
else
out.println("value = {");
out.println("\"https://www.jooq.org\",");
out.println("\"jOOQ version:%s\"", Constants.VERSION);
if (scala)
out.println("),");
else if (kotlin)
out.println("],");
else
out.println("},");
out.println("comments = \"This class is generated by jOOQ\"");
}
out.println(")");
}
if (scala) {
} else if (kotlin)
out.println("@Suppress(\"UNCHECKED_CAST\")");
else
out.println("@%s({ \"all\", \"unchecked\", \"rawtypes\" })", out.ref("java.lang.SuppressWarnings"));
}
use of org.jooq.meta.CatalogDefinition in project jOOQ by jOOQ.
the class GeneratorStrategyWrapper method getJavaIdentifier.
@Override
public String getJavaIdentifier(Definition definition) {
String identifier = getFixedJavaIdentifier(definition);
if (identifier != null)
return identifier;
identifier = convertToIdentifier(delegate.getJavaIdentifier(definition), getTargetLanguage());
// [#1212] Don't trust custom strategies and disambiguate identifiers here
if (definition instanceof ColumnDefinition || definition instanceof AttributeDefinition) {
TypedElementDefinition<?> e = (TypedElementDefinition<?>) definition;
if (identifier.equals(getJavaIdentifier(e.getContainer())))
return identifier + "_";
// [#2781] Disambiguate collisions with the leading package name
if (identifier.equals(getJavaPackageName(e.getContainer()).replaceAll("\\..*", "")))
return identifier + "_";
} else if (definition instanceof TableDefinition) {
SchemaDefinition schema = definition.getSchema();
if (identifier.equals(getJavaIdentifier(schema)))
return identifier + "_";
} else // [#5557] Once more, this causes issues...
if (definition instanceof SchemaDefinition) {
CatalogDefinition catalog = definition.getCatalog();
if (identifier.equals(getJavaIdentifier(catalog)))
return identifier + "_";
}
identifier = overload(definition, Mode.DEFAULT, identifier);
return identifier;
}
use of org.jooq.meta.CatalogDefinition in project jOOQ by jOOQ.
the class PostgresDatabase method getCatalogs0.
@Override
protected List<CatalogDefinition> getCatalogs0() throws SQLException {
List<CatalogDefinition> result = new ArrayList<>();
result.add(new CatalogDefinition(this, "", ""));
return result;
}
use of org.jooq.meta.CatalogDefinition in project jOOQ by jOOQ.
the class HSQLDBDatabase method getCatalogs0.
@Override
protected List<CatalogDefinition> getCatalogs0() throws SQLException {
List<CatalogDefinition> result = new ArrayList<>();
result.add(new CatalogDefinition(this, "", ""));
return result;
}
use of org.jooq.meta.CatalogDefinition in project jOOQ by jOOQ.
the class FirebirdDatabase method getCatalogs0.
@Override
protected List<CatalogDefinition> getCatalogs0() throws SQLException {
List<CatalogDefinition> result = new ArrayList<>();
result.add(new CatalogDefinition(this, "", ""));
return result;
}
Aggregations