package generator
- Alphabetic
- Public
- All
Type Members
-
trait
CamelCaseToSnakeCase extends NamingStrategy
This strategy will make your Scala names adhere to snake_case! In 95% of cases, you probably want to use SnakeCaseToCamelCase instead.
This strategy will make your Scala names adhere to snake_case! In 95% of cases, you probably want to use SnakeCaseToCamelCase instead. (That is, NamingStrategies are "reversed" in terms of intended usage compared to Quill.)
Example (sql name => scala name): someIdent => some_ident
- trait CompanionEmitter extends AnyRef
-
trait
CompilationUnit extends AnyRef
A single unit of compilation, such as a file.
A single unit of compilation, such as a file. Each compilation unit may contain many models.
- trait CompilationUnitEmitter extends AnyRef
- class DefaultCompanionEmitter extends CompanionEmitter
- case class DefaultCompilationUnit(fullName: String, models: Set[Model], imports: Set[Import]) extends CompilationUnit with Product with Serializable
- class DefaultCompilationUnitEmitter extends CompilationUnitEmitter
- case class DefaultModel(table: Table, config: GeneratorConfiguration, inheritances: Inheritances) extends Model with Product with Serializable
- class DefaultModelEmitter extends ModelEmitter
- case class DefaultProperty(column: Column, model: Model, config: GeneratorConfiguration) extends Property with Product with Serializable
- class DefaultPropertyEmitter extends PropertyEmitter
- abstract class DefaultSchemaSlicer extends SchemaSlicer
- class DefaultTypeEmitter extends TypeEmitter
- sealed trait Import extends AnyRef
-
class
ImportSimplifyingTypeEmitter extends DefaultTypeEmitter
Simplifies the names of all imported types and packages.
Simplifies the names of all imported types and packages.
Simplifies "java.lang._", "scala._", "scala.Predef._" and the current compilation unit's package by default, since Scala imports these namespaces by default.
-
case class
Inheritances(map: Map[String, Seq[TypeReference]]) extends Product with Serializable
Inheritances holds all inheritance declarations (extends, with) for the whole schema.
Inheritances holds all inheritance declarations (extends, with) for the whole schema. Please take care to only provide one proper class to extend (although failing to adhere to this will only result in generated code that does not compile).
Note that the inheritance map should use Scala names. Although Scala names depend on the NamingStrategy, Scala names are closer to the actual "A extends B" declaration and thus easier to use in the context of inheritance. Additionally, SQL names are usually case insensitive, which would complicate using SQL names.
Inheritance declarations are based on TypeReference instances. NamedTypeReference can be used for types which don't have a valid representation at generator runtime. For example, we can use it to support extension methods:
Say we generate a case class
Personwith a propertybirthday. We want to add anagefunction to the class, which calculates the current age from the birthday property. Instead of (unsafely) generating the method into the case class, we can extend the case class with a user-defined trait:case class Person(..., birthday: LocalDateTime) extends PersonFunctions
But how do we define the trait so that it can access the values from
Person? Like so:trait PersonFunctions { self: Person => def age: Long = self.birthday.until(LocalDateTime.now(), ChronoUnit.DAYS) }
Only problem: We can't reference PersonFunctions in the generator project as a Type, because it needs the Person case class to even compile. So NamedTypeReference allows you to pass a String instead of a Type for this and other use cases.
-
abstract
class
KeyAsIdProperty extends DefaultProperty
This property class resolves primary and foreign key columns to the correct type reference:
This property class resolves primary and foreign key columns to the correct type reference:
(1) A single-column primary key of a type
Ais resolved to a typeid(A), whereidis an overridable type reference constructor with no default. For example, for a tablepersonwith a primary key columnid, a propertyid: Id[Person]would be emitted if theid(A)type wasId[A]. (2) A foreign key pointing to a single-column primary or unique key (see Column.references) is resolved to the data type of the referenced property. For example, for a tableemployeeswith a foreign key columnperson_id, a propertypersonId: Id[Person]would be emitted, using the typeId[Person]of the referenced property.For a primary key that is also a foreign key, case (2) prevails, since the primary key is then interpreted as the primary key of another table, just replicated here due to a one-to-one relationship. (This is valid in a few edge cases where the original table can't or shouldn't be manipulated to add more columns.)
Usage Note: For Quill support, your id type should either extend AnyVal (which should suffice in most use cases) or come with an encoder and decoder.
In any case, this property only handles single-column primary and foreign keys. You will have to implement some individual handling if you want to type multi-column keys.
-
trait
Literal extends NamingStrategy
Example (sql name => scala name): some_ident => some_ident
-
trait
LowerCase extends NamingStrategy
Example (sql name => scala name): SOME_IDENT => some_ident
-
trait
Model extends AnyRef
Represents a table during transformation to a case class.
- trait ModelEmitter extends AnyRef
-
class
ModelRepository extends AnyRef
A central location to collect all Model objects.
-
case class
NamedTypeReference(fullName: String, typeArguments: Seq[TypeReference] = Seq.empty) extends TypeReference with Product with Serializable
A type reference pointing to a type which can not yet be referenced via typeOf, which is the case when you need to reference types that are either generated by inkwell or depend on types generated by inkwell.
A type reference pointing to a type which can not yet be referenced via typeOf, which is the case when you need to reference types that are either generated by inkwell or depend on types generated by inkwell.
Let's say the application (using inkwell) defines an
Id[A]type, which represents IDs for any typeA. Say you have a tablepersonfrom which a case classPersonis generated. You can resolve the JDBC type of its ID column toId, but you can not provide the type argumentA = PersonsincePersondoes not exist until code generation is finished. In such a case, this class can be used to represent the right type for the property.
Example: - trait NamingStrategy extends AnyRef
-
class
PartitioningSchemaSlicer extends DefaultSchemaSlicer
Partitions the schema into different packages based on a partitioning map.
Partitions the schema into different packages based on a partitioning map. A single model may only be included in one partition. Models not included in any partition will be generated into the base package.
- trait Property extends AnyRef
- trait PropertyEmitter extends AnyRef
-
case class
ScalaTypeReference(t: scala.reflect.api.JavaUniverse.Type, typeArguments: Seq[TypeReference]) extends TypeReference with Product with Serializable
A type reference pointing to a Scala Type, which is the most natural and safe representation possible.
A type reference pointing to a Scala Type, which is the most natural and safe representation possible. However, a Type is not always available, in which case you need to choose a different representation.
Note that t may not always contain proper type arguments (but instead a wildcard type), since they can be custom-set via typeArguments.
Use this class as follows:
import scala.reflect.runtime.universe.typeOf ScalaTypeReference(typeOf[MyType])
Example: -
trait
SchemaSlicer extends AnyRef
Distributes Model objects via CompilationUnit.
Distributes Model objects via CompilationUnit. Each model may only be distributed to a single compilation unit.
Handles the distribution of the whole schema and has the power to decide in which packages specific classes are placed.
-
class
SingleUnitSchemaSlicer extends DefaultSchemaSlicer
Generates the whole schema into a single unit.
-
trait
SnakeCaseToCamelCase extends NamingStrategy
Turns table names to UpperCamelCase and column names to lowerCamelCase.
Turns table names to UpperCamelCase and column names to lowerCamelCase.
Model example (sql name => scala name): some_ident => SomeIdent Property example (sql name => scala name): some_ident => someIdent
-
trait
TypeEmitter extends AnyRef
Turns a type reference into a string.
-
trait
TypeReference extends AnyRef
An abstract type reference used by TypeEmitter to resolve a type.
-
trait
UpperCase extends NamingStrategy
Example (sql name => scala name): some_ident => SOME_IDENT
Value Members
- object CamelCaseToSnakeCase extends CamelCaseToSnakeCase
- object Import
- object Inheritances extends Serializable
- object Literal extends Literal
- object LowerCase extends LowerCase
- object ScalaTypeReference extends Serializable
- object SnakeCaseToCamelCase extends SnakeCaseToCamelCase
- object TypeReference
- object TypeUtil
- object UpperCase extends UpperCase