slick.codegen

SourceCodeGenerator

class SourceCodeGenerator extends AbstractSourceCodeGenerator with OutputHelpers

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.

Source
SourceCodeGenerator.scala
Linear Supertypes
OutputHelpers, AbstractSourceCodeGenerator, StringGeneratorHelpers, AbstractGenerator[String, String, String], GeneratorHelpers[String, String, String], AnyRef, Any
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Grouped
  2. Alphabetic
  3. By inheritance
Inherited
  1. SourceCodeGenerator
  2. OutputHelpers
  3. AbstractSourceCodeGenerator
  4. StringGeneratorHelpers
  5. AbstractGenerator
  6. GeneratorHelpers
  7. AnyRef
  8. Any
Implicitly
  1. by any2stringadd
  2. by any2stringfmt
  3. by any2ArrowAssoc
  4. by any2Ensuring
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SourceCodeGenerator(model: Model)

    model

    Slick data model for which code should be generated.

Type Members

  1. implicit class StringExtensions extends AnyRef

    Slick code generator string extension methods.

  2. type Table = TableDef

    Table generator virtual class

    Table generator virtual class

    Definition Classes
    SourceCodeGeneratorAbstractGenerator
  3. class TableDef extends SourceCodeGenerator.TableDef

    Code generator for table related code

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to StringAdd performed by method any2stringadd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (SourceCodeGenerator, B)

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to ArrowAssoc[SourceCodeGenerator] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. def Table: (model.Table) ⇒ TableDef

    Table generator factory.

    Table generator factory. Override for customization.

    Definition Classes
    SourceCodeGeneratorAbstractGenerator
  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def code: String

    Generates code for the complete model (not wrapped in a package yet)

    Generates code for the complete model (not wrapped in a package yet)

    Definition Classes
    AbstractSourceCodeGenerator
  12. def docWithCode(doc: String, code: String): String

    Assemble doc comment with scala code

    Assemble doc comment with scala code

    Definition Classes
    StringGeneratorHelpersGeneratorHelpers
  13. def ensuring(cond: (SourceCodeGenerator) ⇒ Boolean, msg: ⇒ Any): SourceCodeGenerator

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to Ensuring[SourceCodeGenerator] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: (SourceCodeGenerator) ⇒ Boolean): SourceCodeGenerator

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to Ensuring[SourceCodeGenerator] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean, msg: ⇒ Any): SourceCodeGenerator

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to Ensuring[SourceCodeGenerator] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: Boolean): SourceCodeGenerator

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to Ensuring[SourceCodeGenerator] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. def entityName: (String) ⇒ String

    Maps database table name to entity case class name

    Maps database table name to entity case class name

    Definition Classes
    AbstractGenerator
  18. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  19. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  20. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to StringFormat performed by method any2stringfmt in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  22. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  23. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  24. def indent(code: String): String

    Definition Classes
    GeneratorHelpers
  25. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  26. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  27. final def notify(): Unit

    Definition Classes
    AnyRef
  28. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  29. final def optionType(t: String): String

    Wrap the given type into an Option type

    Wrap the given type into an Option type

    Definition Classes
    StringGeneratorHelpersGeneratorHelpers
  30. def packageCode(profile: String, pkg: String, container: String, parentType: Option[String]): String

    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

    profile

    Slick profile that is imported in the generated package (e.g. slick.driver.H2Driver)

    pkg

    Scala package the generated code is placed in

    container

    The name of a trait and an object the generated code will be placed in within the specified package.

    Definition Classes
    OutputHelpers
  31. def parentType: Option[String]

    The parent type of the generated main trait.

    The parent type of the generated main trait. This can be overridden in subclasses.

    Definition Classes
    OutputHelpers
  32. def parseType(tpe: String): String

    Generates code for a qualified Scala type

    Generates code for a qualified Scala type

    Definition Classes
    StringGeneratorHelpersGeneratorHelpers
  33. val scalaKeywords: Seq[String]

    Words that are reserved keywords in Scala

    Words that are reserved keywords in Scala

    Definition Classes
    GeneratorHelpers
  34. def shouldQuoteIdentifier(s: String): Boolean

    Definition Classes
    StringGeneratorHelpers
  35. val slickTableTermMembersNoArgs: Seq[String]

    Existing term member names in Table[_] that do not take parameters

    Existing term member names in Table[_] that do not take parameters

    Definition Classes
    GeneratorHelpers
  36. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  37. def tableName: (String) ⇒ String

    Maps database table name to Table class and value name

    Maps database table name to Table class and value name

    Definition Classes
    AbstractGenerator
  38. final lazy val tables: Seq[Table]

    Table code generators.

    Table code generators.

    Definition Classes
    AbstractGenerator
  39. final lazy val tablesByName: Map[QualifiedName, Table]

    Table code generators indexed by db table name.

    Table code generators indexed by db table name.

    Definition Classes
    AbstractGenerator
  40. def termName(name: String): String

    Marks a String as a TermName (e.

    Marks a String as a TermName (e.g. for escaping scala keywords)

    Definition Classes
    StringGeneratorHelpersGeneratorHelpers
  41. def toString(): String

    Definition Classes
    AnyRef → Any
  42. def tuple(i: Int): String

    Attributes
    protected
    Definition Classes
    AbstractSourceCodeGenerator
  43. def typeName(name: String): String

    Marks a String as a TypeName (e.

    Marks a String as a TypeName (e.g. for escaping scala keywords)

    Definition Classes
    StringGeneratorHelpersGeneratorHelpers
  44. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  46. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  47. def writeStringToFile(content: String, folder: String, pkg: String, fileName: String): Unit

    Writes given content to a file.

    Writes given content to a file. Ensures the file ends with a newline character.

    Definition Classes
    OutputHelpers
  48. def writeToFile(profile: String, folder: String, pkg: String, container: String = "Tables", fileName: String = "Tables.scala"): Unit

    Generates code and writes it to a file.

    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.

    profile

    Slick profile that is imported in the generated package (e.g. slick.driver.H2Driver)

    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)

    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

    Definition Classes
    OutputHelpers
  49. def [B](y: B): (SourceCodeGenerator, B)

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to ArrowAssoc[SourceCodeGenerator] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implicit Value Members

  1. val self: Any

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to StringAdd performed by method any2stringadd in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (sourceCodeGenerator: StringAdd).self
    Definition Classes
    StringAdd
  2. val self: Any

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to StringFormat performed by method any2stringfmt in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (sourceCodeGenerator: StringFormat).self
    Definition Classes
    StringFormat

Deprecated Value Members

  1. def x: SourceCodeGenerator

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to ArrowAssoc[SourceCodeGenerator] performed by method any2ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (sourceCodeGenerator: ArrowAssoc[SourceCodeGenerator]).x
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use leftOfArrow instead

  2. def x: SourceCodeGenerator

    Implicit information
    This member is added by an implicit conversion from SourceCodeGenerator to Ensuring[SourceCodeGenerator] performed by method any2Ensuring in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (sourceCodeGenerator: Ensuring[SourceCodeGenerator]).x
    Definition Classes
    Ensuring
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use resultOfEnsuring instead

Inherited from OutputHelpers

Inherited from StringGeneratorHelpers

Inherited from AbstractGenerator[String, String, String]

Inherited from GeneratorHelpers[String, String, String]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from SourceCodeGenerator to StringAdd

Inherited by implicit conversion any2stringfmt from SourceCodeGenerator to StringFormat

Inherited by implicit conversion any2ArrowAssoc from SourceCodeGenerator to ArrowAssoc[SourceCodeGenerator]

Inherited by implicit conversion any2Ensuring from SourceCodeGenerator to Ensuring[SourceCodeGenerator]

Basic customization overrides

Output

Ungrouped