use of org.opendaylight.mdsal.binding.model.api.CodeGenerator in project mdsal by opendaylight.
the class JavaFileGenerator method generateFiles.
@VisibleForTesting
static Table<GeneratedFileType, GeneratedFilePath, GeneratedFile> generateFiles(final List<GeneratedType> types, final boolean ignoreDuplicateFiles) {
final Table<GeneratedFileType, GeneratedFilePath, GeneratedFile> result = HashBasedTable.create();
for (Type type : types) {
for (CodeGenerator generator : GENERATORS) {
if (!generator.isAcceptable(type)) {
continue;
}
final GeneratedFileLifecycle kind = type instanceof GeneratedTransferObject && ((GeneratedTransferObject) type).isUnionTypeBuilder() ? GeneratedFileLifecycle.PERSISTENT : GeneratedFileLifecycle.TRANSIENT;
final GeneratedFilePath file = GeneratedFilePath.ofFilePath(type.getPackageName().replace('.', File.separatorChar) + File.separator + generator.getUnitName(type) + ".java");
if (result.contains(GeneratedFileType.SOURCE, file)) {
if (ignoreDuplicateFiles) {
LOG.warn("Naming conflict for type '{}': file with same name already exists and will not be " + "generated.", type.getFullyQualifiedName());
continue;
}
throw new IllegalStateException("Duplicate " + kind + " file '" + file.getPath() + "' for " + type.getFullyQualifiedName());
}
result.put(GeneratedFileType.SOURCE, file, new CodeGeneratorGeneratedFile(kind, generator, type));
}
}
return result;
}
Aggregations