Class AbstractClassGenerator

java.lang.Object
no.sikt.graphitron.generators.abstractions.AbstractClassGenerator
All Implemented Interfaces:
ClassGenerator
Direct Known Subclasses:
AbstractSchemaClassGenerator, CodeInterfaceClassGenerator, TransformerClassGenerator, TypeRegistryClassGenerator, WiringClassGenerator

public abstract class AbstractClassGenerator extends Object implements ClassGenerator
  • Constructor Details

    • AbstractClassGenerator

      public AbstractClassGenerator()
  • Method Details

    • getSpec

      public no.sikt.graphitron.javapoet.TypeSpec.Builder getSpec(String className, List<? extends MethodGenerator> generators)
      Specified by:
      getSpec in interface ClassGenerator
      Parameters:
      className - The name of the class.
      generators - List of method generators that this class should use to generate its methods.
      Returns:
      A completed TypeSpec.Builder for this class, where all methods have already been added.
    • getSpec

      public no.sikt.graphitron.javapoet.TypeSpec.Builder getSpec(String className, MethodGenerator generator)
    • setDependencies

      protected void setDependencies(List<? extends MethodGenerator> generators, no.sikt.graphitron.javapoet.TypeSpec.Builder spec)
      Add all the dependency fields for this class.
      Parameters:
      generators - Generators to extract dependencies from.
    • generateAllAsMap

      public Map<String,String> generateAllAsMap()
      Description copied from interface: ClassGenerator
      Generate the classes and write them to a String.
      Specified by:
      generateAllAsMap in interface ClassGenerator
    • generateAllToDirectory

      public void generateAllToDirectory(String path, String packagePath)
      Specified by:
      generateAllToDirectory in interface ClassGenerator
      Parameters:
      path - The path to the output directory.
      packagePath - The package path that this class should be written to.
    • writeToFile

      public void writeToFile(no.sikt.graphitron.javapoet.TypeSpec generatedClass, String path, String packagePath)
      Description copied from interface: ClassGenerator
      Create the JavaFile for this class, add any common static imports and write it to file.
      Specified by:
      writeToFile in interface ClassGenerator
      Parameters:
      generatedClass - A complete javapoet TypeSpec.
      path - The path to the output directory.
      packagePath - The package path that this class should be written to.
    • writeToFile

      public void writeToFile(no.sikt.graphitron.javapoet.TypeSpec generatedClass, String path, String packagePath, String directoryOverride)
      Description copied from interface: ClassGenerator
      Create the JavaFile for this class, add any common static imports and write it to file.
      Specified by:
      writeToFile in interface ClassGenerator
      Parameters:
      generatedClass - A complete javapoet TypeSpec.
      path - The path to the output directory.
      packagePath - The package path that this class should be written to.
      directoryOverride - Override the directory within the package where the class is saved to.
    • writeToString

      public String writeToString(no.sikt.graphitron.javapoet.TypeSpec generatedClass)
      Description copied from interface: ClassGenerator
      Create the JavaFile for this class, add any common static imports and render the file as a string.
      Specified by:
      writeToString in interface ClassGenerator
      Parameters:
      generatedClass - A complete javapoet TypeSpec.
    • getGeneratedClassName

      public no.sikt.graphitron.javapoet.ClassName getGeneratedClassName(String name)
      Parameters:
      name - Name of the class.
      Returns:
      ClassName based on the default output package and save directory.