All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.curs.hurdygurdy.JavaCodegen Maven / Gradle / Ivy

There is a newer version: 2.01
Show newest version
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