ru.curs.hurdygurdy.JavaCodegen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hurdy-gurdy Show documentation
Show all versions of hurdy-gurdy Show documentation
Client/server code generator for OpenAPI
package ru.curs.hurdygurdy;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.TypeSpec;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.function.BiConsumer;
public class JavaCodegen extends Codegen {
public JavaCodegen(String rootPackage, boolean generateResponseParameter, boolean generateApiInterface) {
super(rootPackage, new TypeProducersFactory<>() {
@Override
public TypeDefiner createTypeDefiner(BiConsumer typeSpecBiConsumer) {
return new JavaTypeDefiner(rootPackage, typeSpecBiConsumer);
}
@Override
public List> typeSpecExtractors(TypeDefiner typeDefiner) {
return List.of(new JavaDTOExtractor(typeDefiner),
new JavaAPIExtractor(typeDefiner, generateResponseParameter, generateApiInterface));
}
});
}
@Override
void writeFile(Path resultDirectory, String packageName, TypeSpec typeSpec) throws IOException {
JavaFile javaFile = JavaFile.builder(packageName, typeSpec).build();
javaFile.writeTo(resultDirectory);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy