use of org.jooq.meta.UDTDefinition in project jOOQ by jOOQ.
the class JavaGenerator method generateUDTRecords.
/**
* Generating UDT record classes
*/
protected void generateUDTRecords(SchemaDefinition schema) {
log.info("Generating UDT records");
for (UDTDefinition udt : database.getUDTs(schema)) {
try {
generateUDTRecord(udt);
} catch (Exception e) {
log.error("Error while generating UDT record " + udt, e);
}
}
watch.splitInfo("UDT records generated");
}
use of org.jooq.meta.UDTDefinition in project jOOQ by jOOQ.
the class JavaGenerator method generateUDTInterfaces.
protected void generateUDTInterfaces(SchemaDefinition schema) {
log.info("Generating UDT interfaces");
for (UDTDefinition udt : database.getUDTs(schema)) {
try {
generateUDTInterface(udt);
} catch (Exception e) {
log.error("Error while generating UDT interface " + udt, e);
}
}
watch.splitInfo("UDT interfaces generated");
}
use of org.jooq.meta.UDTDefinition in project jOOQ by jOOQ.
the class JavaGenerator method isArrayOfUDTs.
private boolean isArrayOfUDTs(final TypedElementDefinition<?> t, final JavaTypeResolver r) {
// [#11183] TODO: Move this to DataTypeDefinition?
String javaType = t.getType(r).getJavaType(r);
if (!isArrayType(javaType))
return false;
String baseType = getArrayBaseType(javaType);
for (UDTDefinition udt : t.getDatabase().getUDTs()) if (baseType.equals(getStrategy().getFullJavaClassName(udt, Mode.RECORD)))
return true;
return false;
}
use of org.jooq.meta.UDTDefinition in project jOOQ by jOOQ.
the class JavaGenerator method generateUDTs.
protected void generateUDTs(SchemaDefinition schema) {
log.info("Generating UDTs");
for (UDTDefinition udt : database.getUDTs(schema)) {
try {
generateUDT(schema, udt);
} catch (Exception e) {
log.error("Error while generating udt " + udt, e);
}
}
watch.splitInfo("UDTs generated");
}
use of org.jooq.meta.UDTDefinition in project jOOQ by jOOQ.
the class JavaGenerator method generateUDTReferences.
/**
* Generating central static udt access
*/
protected void generateUDTReferences(Definition schemaOrPackage) {
String logSuffix = schemaOrPackage instanceof SchemaDefinition ? "" : (" for package " + schemaOrPackage.getOutputName());
log.info("Generating UDT references" + logSuffix);
JavaWriter out = newJavaWriter(getStrategy().getGlobalReferencesFile(schemaOrPackage, UDTDefinition.class));
printGlobalReferencesPackage(out, schemaOrPackage, UDTDefinition.class);
if (!kotlin) {
printClassJavadoc(out, "Convenience access to all UDTs in " + schemaNameOrDefault(schemaOrPackage) + ".");
printClassAnnotations(out, schemaOrPackage, Mode.DEFAULT);
}
final String referencesClassName = getStrategy().getGlobalReferencesJavaClassName(schemaOrPackage, UDTDefinition.class);
if (scala)
out.println("%sobject %s {", visibility(), referencesClassName);
else if (kotlin) {
} else
out.println("%sclass %s {", visibility(), referencesClassName);
List<UDTDefinition> udts = new ArrayList<>();
if (schemaOrPackage instanceof SchemaDefinition) {
for (UDTDefinition udt : database.getUDTs((SchemaDefinition) schemaOrPackage)) if (udt.getPackage() == null)
udts.add(udt);
} else
udts.addAll(database.getUDTs((PackageDefinition) schemaOrPackage));
for (UDTDefinition udt : udts) {
final String className = out.ref(getStrategy().getFullJavaClassName(udt));
final String id = getStrategy().getJavaIdentifier(udt);
final String fullId = getStrategy().getFullJavaIdentifier(udt);
out.javadoc("The type <code>%s</code>", udt.getQualifiedOutputName());
if (scala)
out.println("%sdef %s = %s", visibility(), id, fullId);
else if (kotlin)
out.println("%sval %s: %s = %s", visibility(), id, className, fullId);
else
out.println("%sstatic final %s %s = %s;", visibility(), className, id, fullId);
}
generateUDTReferencesClassFooter(schemaOrPackage, out);
if (!kotlin)
out.println("}");
closeJavaWriter(out);
watch.splitInfo("UDT references generated" + logSuffix);
if (schemaOrPackage instanceof SchemaDefinition)
for (PackageDefinition pkg : database.getPackages((SchemaDefinition) schemaOrPackage)) if (!pkg.getUDTs().isEmpty())
generateUDTReferences(pkg);
}
Aggregations