[history/serdha] Renaming '*Creator' -> '*Constructor'
This commit is contained in:
parent
8a6de9d2fa
commit
d0f5bd8386
@ -1,10 +1,10 @@
|
|||||||
package ru.landgrafhomyak.db.serdha0.api.module
|
package ru.landgrafhomyak.db.serdha0.api.module
|
||||||
|
|
||||||
import ru.landgrafhomyak.db.serdha0.api.table.Table
|
import ru.landgrafhomyak.db.serdha0.api.table.Table
|
||||||
import ru.landgrafhomyak.db.serdha0.api.queries.QueryCreator
|
import ru.landgrafhomyak.db.serdha0.api.queries.QueryConstructor
|
||||||
import ru.landgrafhomyak.db.serdha0.api.runtime.SynchronizedDatabase
|
import ru.landgrafhomyak.db.serdha0.api.runtime.SynchronizedDatabase
|
||||||
import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction
|
import ru.landgrafhomyak.db.serdha0.api.runtime.Transaction
|
||||||
import ru.landgrafhomyak.db.serdha0.api.table.CreateTableScope
|
import ru.landgrafhomyak.db.serdha0.api.table.TableConstructor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope methods for creating new [module template][ModuleTemplate].
|
* Scope methods for creating new [module template][ModuleTemplate].
|
||||||
@ -13,32 +13,6 @@ import ru.landgrafhomyak.db.serdha0.api.table.CreateTableScope
|
|||||||
* @see ModuleTemplate.ModuleCreator.createSchema
|
* @see ModuleTemplate.ModuleCreator.createSchema
|
||||||
*/
|
*/
|
||||||
public interface CreateModuleScope {
|
public interface CreateModuleScope {
|
||||||
/**
|
|
||||||
* Functional interface for creating table.
|
|
||||||
*
|
|
||||||
* Can be implemented like a companion object that just calls [TableUserExtension]'s constructor with the same or similar signature.
|
|
||||||
*
|
|
||||||
* @param TableUserExtension User's type for containing table-related descriptors.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createTable
|
|
||||||
* @see CreateModuleScope.createSessionScopeTemporaryTable
|
|
||||||
* @see CreateModuleScope.createTransactionScopeTemporaryTable
|
|
||||||
* @see UpgradeModuleScope.TableUpgrade
|
|
||||||
*/
|
|
||||||
public interface TableCreator<TableUserExtension : Any> {
|
|
||||||
/**
|
|
||||||
* Scope method that uses [creator] to initialize table schema.
|
|
||||||
*
|
|
||||||
* @param creator Object with descriptor providers and factories.
|
|
||||||
* @return User's object with descriptors for future access.
|
|
||||||
*
|
|
||||||
* @see CreateModuleScope.createTable
|
|
||||||
* @see CreateModuleScope.createSessionScopeTemporaryTable
|
|
||||||
* @see CreateModuleScope.createTransactionScopeTemporaryTable
|
|
||||||
* @see UpgradeModuleScope.TableUpgrade
|
|
||||||
*/
|
|
||||||
public fun createTable(creator: CreateTableScope<TableUserExtension>): TableUserExtension
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates table in [specified namespace][namespace] with [specified name][name] and stores it in the database.
|
* Creates table in [specified namespace][namespace] with [specified name][name] and stores it in the database.
|
||||||
@ -52,7 +26,7 @@ public interface CreateModuleScope {
|
|||||||
* @param initializer Table-related descriptors initializer.
|
* @param initializer Table-related descriptors initializer.
|
||||||
* @return Table descriptor.
|
* @return Table descriptor.
|
||||||
*/
|
*/
|
||||||
public fun <TableUserExtension : Any> createTable(namespace: Namespace, name: String, initializer: TableCreator<TableUserExtension>): Table<TableUserExtension, Nothing>
|
public fun <TableUserExtension : Any> createTable(namespace: Namespace, name: String, initializer: TableConstructor<TableUserExtension>): Table<TableUserExtension, Nothing>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a temporary table that exits only until connection to the database not [closed][SynchronizedDatabase._close].
|
* Creates a temporary table that exits only until connection to the database not [closed][SynchronizedDatabase._close].
|
||||||
@ -65,7 +39,7 @@ public interface CreateModuleScope {
|
|||||||
* @param initializer Table-related descriptors initializer.
|
* @param initializer Table-related descriptors initializer.
|
||||||
* @return Table descriptor.
|
* @return Table descriptor.
|
||||||
*/
|
*/
|
||||||
public fun <TableUserExtension : Any> createSessionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableCreator<TableUserExtension>): Table<TableUserExtension, Nothing>
|
public fun <TableUserExtension : Any> createSessionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableConstructor<TableUserExtension>): Table<TableUserExtension, Nothing>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a temporary table that exits only inside [transaction][Transaction] and auto-deleted (or cleared, depends on driver implementation) when it [finished][Transaction._assertTransactionFinishedAndReleaseResources].
|
* Creates a temporary table that exits only inside [transaction][Transaction] and auto-deleted (or cleared, depends on driver implementation) when it [finished][Transaction._assertTransactionFinishedAndReleaseResources].
|
||||||
@ -78,17 +52,17 @@ public interface CreateModuleScope {
|
|||||||
* @param initializer Table-related descriptors initializer.
|
* @param initializer Table-related descriptors initializer.
|
||||||
* @return Table descriptor.
|
* @return Table descriptor.
|
||||||
*/
|
*/
|
||||||
public fun <TableUserExtension : Any> createTransactionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableCreator<TableUserExtension>): Table<TableUserExtension, Nothing>
|
public fun <TableUserExtension : Any> createTransactionScopeTemporaryTable(namespace: Namespace, name: String, initializer: TableConstructor<TableUserExtension>): Table<TableUserExtension, Nothing>
|
||||||
|
|
||||||
public val queries: QueryCreator.Scope
|
public val queries: QueryConstructor.Scope
|
||||||
|
|
||||||
public val temporarySubqueries: QueryCreator.Scope
|
public val temporarySubqueries: QueryConstructor.Scope
|
||||||
|
|
||||||
public val moduleConfiguringTemporaryQueries: QueryCreator.Scope
|
public val moduleConfiguringTemporaryQueries: QueryConstructor.Scope
|
||||||
|
|
||||||
public fun <qUE : Any> createQuery(creator: QueryCreator<qUE>): qUE
|
public fun <qUE : Any> createQuery(creator: QueryConstructor<qUE>): qUE
|
||||||
|
|
||||||
public fun <qUE : Any> createModuleConfiguringTemporaryQuery(creator: QueryCreator<qUE>): qUE
|
public fun <qUE : Any> createModuleConfiguringTemporaryQuery(creator: QueryConstructor<qUE>): qUE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces [specified namespace][rootNs] with schema provided by [template].
|
* Replaces [specified namespace][rootNs] with schema provided by [template].
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
package ru.landgrafhomyak.db.serdha0.api.table
|
|
||||||
|
|
||||||
import ru.landgrafhomyak.db.serdha0.api.misc.Column
|
|
||||||
import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType
|
|
||||||
|
|
||||||
public interface CreateTableScope<tUE : Any> {
|
|
||||||
public val types: DatabaseType.Provider
|
|
||||||
|
|
||||||
public fun <RT, DT : DatabaseType<RT>> column(name: String, type: DT): Column<RT, DT, tUE>
|
|
||||||
|
|
||||||
public fun index(name: String, vararg columns: Column<*, *, tUE>): Index<tUE>
|
|
||||||
|
|
||||||
public fun uniqueIndex(name: String, distinctNulls: Boolean, vararg columns: Column<*, *, tUE>): UniqueIndex<tUE>
|
|
||||||
public fun <cUE : Any> checkConstraint(name: String, creator: CheckConstraint.Creator<cUE, tUE>, recheckExistingRows: Boolean = false): CheckConstraint<tUE>
|
|
||||||
public fun <cUE : Any, RT : Any, DT : DatabaseType<RT>> defaultValue(c: Column<RT, DT, tUE>, creator: DefaultConstraint.Creator<cUE, RT, DT, tUE>): DefaultConstraint<tUE>
|
|
||||||
|
|
||||||
@Suppress("PropertyName")
|
|
||||||
public val rowId_column: Column<RowId<tUE>, DatabaseType<RowId<tUE>>, tUE>
|
|
||||||
|
|
||||||
@Suppress("PropertyName")
|
|
||||||
public val rowId_uniqueConstraint: UniqueIndex<tUE>
|
|
||||||
|
|
||||||
public fun <ttUE : Any> selfRowReference(
|
|
||||||
columnName: String,
|
|
||||||
onDelete: ForeignRowReference.OnDelete,
|
|
||||||
): ForeignRowReference<tUE, tUE, RowId<tUE>, DatabaseType.ROW_ID<tUE>>
|
|
||||||
|
|
||||||
public fun <ttUE : Any, RT, DT : DatabaseType<RT>> selfRowReference(
|
|
||||||
columnName: String,
|
|
||||||
type: DT,
|
|
||||||
onDelete: ForeignRowReference.OnDelete,
|
|
||||||
): ForeignRowReference<tUE, tUE, RT, DT>
|
|
||||||
|
|
||||||
public fun <ttUE : Any> foreignRowReference(
|
|
||||||
columnName: String,
|
|
||||||
toTable: Table<ttUE, *>,
|
|
||||||
onDelete: ForeignRowReference.OnDelete,
|
|
||||||
): ForeignRowReference<tUE, ttUE, RowId<ttUE>, DatabaseType.ROW_ID<ttUE>>
|
|
||||||
|
|
||||||
public fun <ttUE : Any, RT, DT : DatabaseType<RT>> foreignRowReference(
|
|
||||||
columnName: String,
|
|
||||||
type: DT,
|
|
||||||
toTable: Table<ttUE, *>,
|
|
||||||
onDelete: ForeignRowReference.OnDelete,
|
|
||||||
): ForeignRowReference<tUE, ttUE, RT, DT>
|
|
||||||
}
|
|
@ -0,0 +1,52 @@
|
|||||||
|
package ru.landgrafhomyak.db.serdha0.api.table
|
||||||
|
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.misc.Column
|
||||||
|
import ru.landgrafhomyak.db.serdha0.api.misc.DatabaseType
|
||||||
|
|
||||||
|
|
||||||
|
public interface TableConstructor<TableUserExtension : Any> {
|
||||||
|
public fun createTable(context: Scope<TableUserExtension>): TableUserExtension
|
||||||
|
|
||||||
|
|
||||||
|
public interface Scope<tUE : Any> {
|
||||||
|
public val types: DatabaseType.Provider
|
||||||
|
|
||||||
|
public fun <RT, DT : DatabaseType<RT>> column(name: String, type: DT): Column<RT, DT, tUE>
|
||||||
|
|
||||||
|
public fun index(name: String, vararg columns: Column<*, *, tUE>): Index<tUE>
|
||||||
|
|
||||||
|
public fun uniqueIndex(name: String, distinctNulls: Boolean, vararg columns: Column<*, *, tUE>): UniqueIndex<tUE>
|
||||||
|
public fun <cUE : Any> checkConstraint(name: String, creator: CheckConstraint.Creator<cUE, tUE>, recheckExistingRows: Boolean = false): CheckConstraint<tUE>
|
||||||
|
public fun <cUE : Any, RT : Any, DT : DatabaseType<RT>> defaultValue(c: Column<RT, DT, tUE>, creator: DefaultConstraint.Creator<cUE, RT, DT, tUE>): DefaultConstraint<tUE>
|
||||||
|
|
||||||
|
@Suppress("PropertyName")
|
||||||
|
public val rowId_column: Column<RowId<tUE>, DatabaseType<RowId<tUE>>, tUE>
|
||||||
|
|
||||||
|
@Suppress("PropertyName")
|
||||||
|
public val rowId_uniqueConstraint: UniqueIndex<tUE>
|
||||||
|
|
||||||
|
public fun selfRowReference(
|
||||||
|
columnName: String,
|
||||||
|
onDelete: ForeignRowReference.OnDelete,
|
||||||
|
): ForeignRowReference<tUE, tUE, RowId<tUE>, DatabaseType.ROW_ID<tUE>>
|
||||||
|
|
||||||
|
public fun <RT, DT : DatabaseType<RT>> selfRowReference(
|
||||||
|
columnName: String,
|
||||||
|
type: DT,
|
||||||
|
onDelete: ForeignRowReference.OnDelete,
|
||||||
|
): ForeignRowReference<tUE, tUE, RT, DT>
|
||||||
|
|
||||||
|
public fun <ttUE : Any> foreignRowReference(
|
||||||
|
columnName: String,
|
||||||
|
toTable: Table<ttUE, *>,
|
||||||
|
onDelete: ForeignRowReference.OnDelete,
|
||||||
|
): ForeignRowReference<tUE, ttUE, RowId<ttUE>, DatabaseType.ROW_ID<ttUE>>
|
||||||
|
|
||||||
|
public fun <ttUE : Any, RT, DT : DatabaseType<RT>> foreignRowReference(
|
||||||
|
columnName: String,
|
||||||
|
type: DT,
|
||||||
|
toTable: Table<ttUE, *>,
|
||||||
|
onDelete: ForeignRowReference.OnDelete,
|
||||||
|
): ForeignRowReference<tUE, ttUE, RT, DT>
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user