A customizable code generator for working with Slick.
For usage information please see the corresponding part of the Slick documentation.
The implementation is structured into a small hierarchy of sub-generators responsible for different fragments of the complete output. The implementation of each sub-generator can be swapped out for a customized one by overriding the corresponding factory method. SourceCodeGenerator contains a factory method Table, which it uses to generate a sub-generator for each table. The sub-generator Table in turn contains sub-generators for Table classes, entity case classes, columns, key, indices, etc. Custom sub-generators can easily be added as well.
Within the sub-generators the relevant part of the Slick data model can
be accessed to drive the code generation.
Of coures it makes sense to integrate this into your build process.
Attributes
- model
Slick data model for which code should be generated.
- Companion:
- object
- Source:
- SourceCodeGenerator.scala
- Graph
- Supertypes
Members list
Basic customization overrides
Code generator for table related code
Code generator for table related code
Attributes
- model
corresponding Slick meta model component
- Inherited from:
- AbstractGenerator
- Source:
- AbstractGenerator.scala
- Graph
- Supertypes
- trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass Any
- Known subtypes
- class SourceCodeTableDef
Table generator factory. Override for customization.
Generates code for the complete model (not wrapped in a package yet)
Generates code for the complete model (not wrapped in a package yet)
Attributes
- Inherited from:
- AbstractSourceCodeGenerator
- Source:
- AbstractSourceCodeGenerator.scala
Generates code for the container class (not wrapped in a package yet)
Generates code for the container class (not wrapped in a package yet)
Attributes
- Inherited from:
- AbstractSourceCodeGenerator
- Source:
- AbstractSourceCodeGenerator.scala
Generates code for the DDL statement.
Generates code for the DDL statement.
Attributes
- Inherited from:
- AbstractSourceCodeGenerator
- Source:
- AbstractSourceCodeGenerator.scala
Generates a map that associates the table name with its generated code (not wrapped in a package yet).
Generates a map that associates the table name with its generated code (not wrapped in a package yet).
Attributes
- Inherited from:
- AbstractSourceCodeGenerator
- Source:
- AbstractSourceCodeGenerator.scala
Maps database table name to entity case class name
Maps database table name to entity case class name
Attributes
- Inherited from:
- AbstractGenerator
- Source:
- AbstractGenerator.scala
Generates code providing the data model as trait and object in a Scala package
Generates code providing the data model as trait and object in a Scala package
Attributes
- container
The name of a trait and an object the generated code will be placed in within the specified package.
- pkg
Scala package the generated code is placed in
- profile
Slick profile that is imported in the generated package (e.g. slick.jdbc.H2Profile)
- Inherited from:
- OutputHelpers
- Source:
- OutputHelpers.scala
Generates code providing the stand-alone slick data model for immediate use.
Generates code providing the stand-alone slick data model for immediate use.
Attributes
- container
The name of a trait and an object the generated code will be placed in within the specified package.
- pkg
Scala package the generated code is placed in
- profile
Slick profile that is imported in the generated package (e.g. scala.slick.driver.H2Driver)
- Inherited from:
- OutputHelpers
- Source:
- OutputHelpers.scala
Generates code for the given table. The tableName and tableCode parameters should come from the #codePerTable map.
Generates code for the given table. The tableName and tableCode parameters should come from the #codePerTable map.
Attributes
- container
The name of the container
- pkg
Scala package the generated code is placed in
- tableCode
: the generated code for the table.
- tableName
: the name of the table
- Inherited from:
- OutputHelpers
- Source:
- OutputHelpers.scala
Maps database table name to Table class and value name
Maps database table name to Table class and value name
Attributes
- Inherited from:
- AbstractGenerator
- Source:
- AbstractGenerator.scala
Output
Writes given content to a file. Ensures the file ends with a newline character.
Writes given content to a file. Ensures the file ends with a newline character.
Attributes
- Inherited from:
- OutputHelpers
- Source:
- OutputHelpers.scala
Generates code and writes it to a file. Creates a folder structure for the given package inside the given srcFolder and places the new file inside or overrides the existing one.
Generates code and writes it to a file. Creates a folder structure for the given package inside the given srcFolder and places the new file inside or overrides the existing one.
Attributes
- container
The name of a trait and an object the generated code will be placed in within the specified package.
- fileName
Name of the output file, to which the code will be written
- folder
target folder, in which the package structure folders are placed
- pkg
Scala package the generated code is placed in (a subfolder structure will be created within srcFolder)
- profile
Slick profile that is imported in the generated package (e.g. slick.jdbc.H2Profile)
- Inherited from:
- OutputHelpers
- Source:
- OutputHelpers.scala
Generates code and writes it to multiple files. Creates a folder structure for the given package inside the given srcFolder and places the new files inside or overrides the existing one.
Generates code and writes it to multiple files. Creates a folder structure for the given package inside the given srcFolder and places the new files inside or overrides the existing one.
Attributes
- container
The name of a trait and an object the generated code will be placed in within the specified package.
- folder
target folder, in which the output files are placed
- pkg
Scala package the generated code is placed in (a subfolder structure will be created within srcFolder)
- profile
Slick profile that is imported in the generated package (e.g. scala.slick.driver.H2Driver)
- Inherited from:
- OutputHelpers
- Source:
- OutputHelpers.scala
Type members
Classlikes
Attributes
- Source:
- SourceCodeGenerator.scala
- Graph
- Supertypes
- class AbstractTableDeftrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass Any
Inherited classlikes
Attributes
- Inherited from:
- AbstractSourceCodeGenerator
- Source:
- AbstractSourceCodeGenerator.scala
- Graph
- Supertypes
- class AbstractTableDeftrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass Any
- Known subtypes
- class SourceCodeTableDef
Slick code generator string extension methods. (Warning: Not unicode-safe, uses String#apply)
Slick code generator string extension methods. (Warning: Not unicode-safe, uses String#apply)
Attributes
- Inherited from:
- GeneratorHelpers
- Source:
- AbstractGenerator.scala
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
Types
Table generator virtual class
Value members
Inherited methods
Assemble doc comment with scala code
Assemble doc comment with scala code
Attributes
- Inherited from:
- StringGeneratorHelpers
- Source:
- AbstractSourceCodeGenerator.scala
Attributes
- Inherited from:
- AbstractSourceCodeGenerator
- Source:
- AbstractSourceCodeGenerator.scala
Attributes
- Inherited from:
- GeneratorHelpers
- Source:
- AbstractGenerator.scala
Wrap the given type into an Option type
Wrap the given type into an Option type
Attributes
- Inherited from:
- StringGeneratorHelpers
- Source:
- AbstractSourceCodeGenerator.scala
The parent type of the generated main trait. This can be overridden in subclasses.
The parent type of the generated main trait. This can be overridden in subclasses.
Attributes
- Inherited from:
- OutputHelpers
- Source:
- OutputHelpers.scala
Generates code for a qualified Scala type
Generates code for a qualified Scala type
Attributes
- Inherited from:
- StringGeneratorHelpers
- Source:
- AbstractSourceCodeGenerator.scala
Attributes
- Inherited from:
- OutputHelpers
- Source:
- OutputHelpers.scala
Attributes
- Inherited from:
- StringGeneratorHelpers
- Source:
- AbstractSourceCodeGenerator.scala
Marks a String as a TermName (e.g. for escaping scala keywords)
Marks a String as a TermName (e.g. for escaping scala keywords)
Attributes
- Inherited from:
- StringGeneratorHelpers
- Source:
- AbstractSourceCodeGenerator.scala
Attributes
- Inherited from:
- AbstractSourceCodeGenerator
- Source:
- AbstractSourceCodeGenerator.scala
Marks a String as a TypeName (e.g. for escaping scala keywords)
Marks a String as a TypeName (e.g. for escaping scala keywords)
Attributes
- Inherited from:
- StringGeneratorHelpers
- Source:
- AbstractSourceCodeGenerator.scala
Inherited fields
Enables DDL Generation.
Words that are reserved keywords in Scala
Words that are reserved keywords in Scala
Attributes
- Inherited from:
- GeneratorHelpers
- Source:
- AbstractGenerator.scala
Existing term member names in Table[_] that do not take parameters
Existing term member names in Table[_] that do not take parameters
Attributes
- Inherited from:
- GeneratorHelpers
- Source:
- AbstractGenerator.scala
Table code generators.
Table code generators indexed by db table name.
Table code generators indexed by db table name.
Attributes
- Inherited from:
- AbstractGenerator
- Source:
- AbstractGenerator.scala
Implicits
Inherited implicits
Slick code generator string extension methods. (Warning: Not unicode-safe, uses String#apply)
Slick code generator string extension methods. (Warning: Not unicode-safe, uses String#apply)
Attributes
- Inherited from:
- GeneratorHelpers
- Source:
- AbstractGenerator.scala