Class DBClassGenerator

All Implemented Interfaces:
ClassGenerator
Direct Known Subclasses:
SelectHelperDBClassGenerator

public class DBClassGenerator extends AbstractSchemaClassGenerator<ObjectDefinition>
Class generator that keeps track of all method generators for DB queries.
  • Field Details

  • Constructor Details

    • DBClassGenerator

      public DBClassGenerator(ProcessedSchema processedSchema)
  • Method Details

    • generateAll

      public List<no.sikt.graphitron.javapoet.TypeSpec> generateAll()
      Description copied from interface: ClassGenerator
      Generate the classes and return the list of TypeSpecs.
    • generate

      public no.sikt.graphitron.javapoet.TypeSpec generate(ObjectDefinition target)
      Specified by:
      generate in class AbstractSchemaClassGenerator<ObjectDefinition>
      Parameters:
      target - A GenerationTarget object representing a source from which a class should be generated.
      Returns:
      A complete class in the form of a javapoet TypeSpec.
    • getDefaultSaveDirectoryName

      public String getDefaultSaveDirectoryName()
      Returns:
      The final directory path within the package where the classes are ultimately saved.
    • getSpec

      public no.sikt.graphitron.javapoet.TypeSpec.Builder getSpec(String className, List<? extends MethodGenerator> generators)
      Specified by:
      getSpec in interface ClassGenerator
      Overrides:
      getSpec in class AbstractClassGenerator
      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.
    • getStaticImports

      protected Set<Class<?>> getStaticImports()
    • 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
      Overrides:
      writeToFile in class AbstractClassGenerator
      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
      Overrides:
      writeToString in class AbstractClassGenerator
      Parameters:
      generatedClass - A complete javapoet TypeSpec.
    • getFileNameSuffix

      public String getFileNameSuffix()
      Returns:
      The suffix that is to be added to the end of file names generated by this class.
    • warnOrCrashIfMethodsExceedsBounds

      protected void warnOrCrashIfMethodsExceedsBounds(no.sikt.graphitron.javapoet.TypeSpec typeSpec)