/*
 * This file is generated by jOOQ.
 */
package jooq.main.tables


import jooq.main.Public
import jooq.main.keys.COURSE_LIBRARY_PKEY
import jooq.main.keys.COURSE_LIBRARY__COURSE_LIBRARY_COURSE_ID_FKEY
import jooq.main.keys.COURSE_LIBRARY__COURSE_LIBRARY_LIBRARY_ID_FKEY
import jooq.main.tables.Course.CoursePath
import jooq.main.tables.Library.LibraryPath
import jooq.main.tables.records.CourseLibraryRecord

import kotlin.collections.Collection
import kotlin.collections.List

import org.jooq.Condition
import org.jooq.Field
import org.jooq.ForeignKey
import org.jooq.InverseForeignKey
import org.jooq.Name
import org.jooq.Path
import org.jooq.PlainSQL
import org.jooq.QueryPart
import org.jooq.Record
import org.jooq.SQL
import org.jooq.Schema
import org.jooq.Select
import org.jooq.Stringly
import org.jooq.Table
import org.jooq.TableField
import org.jooq.TableOptions
import org.jooq.UniqueKey
import org.jooq.impl.DSL
import org.jooq.impl.Internal
import org.jooq.impl.SQLDataType
import org.jooq.impl.TableImpl


/**
 * This class is generated by jOOQ.
 */
@Suppress("UNCHECKED_CAST")
open class CourseLibrary(
    alias: Name,
    path: Table<out Record>?,
    childPath: ForeignKey<out Record, CourseLibraryRecord>?,
    parentPath: InverseForeignKey<out Record, CourseLibraryRecord>?,
    aliased: Table<CourseLibraryRecord>?,
    parameters: Array<Field<*>?>?,
    where: Condition?
): TableImpl<CourseLibraryRecord>(
    alias,
    Public.PUBLIC,
    path,
    childPath,
    parentPath,
    aliased,
    parameters,
    DSL.comment(""),
    TableOptions.table(),
    where,
) {
    companion object {

        /**
         * The reference instance of <code>public.course_library</code>
         */
        val COURSE_LIBRARY: CourseLibrary = CourseLibrary()
    }

    /**
     * The class holding records for this type
     */
    override fun getRecordType(): Class<CourseLibraryRecord> = CourseLibraryRecord::class.java

    /**
     * The column <code>public.course_library.course_id</code>.
     */
    val COURSE_ID: TableField<CourseLibraryRecord, Long?> = createField(DSL.name("course_id"), SQLDataType.BIGINT.nullable(false), this, "")

    /**
     * The column <code>public.course_library.library_id</code>.
     */
    val LIBRARY_ID: TableField<CourseLibraryRecord, Long?> = createField(DSL.name("library_id"), SQLDataType.BIGINT.nullable(false), this, "")

    private constructor(alias: Name, aliased: Table<CourseLibraryRecord>?): this(alias, null, null, null, aliased, null, null)
    private constructor(alias: Name, aliased: Table<CourseLibraryRecord>?, parameters: Array<Field<*>?>?): this(alias, null, null, null, aliased, parameters, null)
    private constructor(alias: Name, aliased: Table<CourseLibraryRecord>?, where: Condition?): this(alias, null, null, null, aliased, null, where)

    /**
     * Create an aliased <code>public.course_library</code> table reference
     */
    constructor(alias: String): this(DSL.name(alias))

    /**
     * Create an aliased <code>public.course_library</code> table reference
     */
    constructor(alias: Name): this(alias, null)

    /**
     * Create a <code>public.course_library</code> table reference
     */
    constructor(): this(DSL.name("course_library"), null)

    constructor(path: Table<out Record>, childPath: ForeignKey<out Record, CourseLibraryRecord>?, parentPath: InverseForeignKey<out Record, CourseLibraryRecord>?): this(Internal.createPathAlias(path, childPath, parentPath), path, childPath, parentPath, COURSE_LIBRARY, null, null)

    /**
     * A subtype implementing {@link Path} for simplified path-based joins.
     */
    open class CourseLibraryPath : CourseLibrary, Path<CourseLibraryRecord> {
        constructor(path: Table<out Record>, childPath: ForeignKey<out Record, CourseLibraryRecord>?, parentPath: InverseForeignKey<out Record, CourseLibraryRecord>?): super(path, childPath, parentPath)
        private constructor(alias: Name, aliased: Table<CourseLibraryRecord>): super(alias, aliased)
        override fun `as`(alias: String): CourseLibraryPath = CourseLibraryPath(DSL.name(alias), this)
        override fun `as`(alias: Name): CourseLibraryPath = CourseLibraryPath(alias, this)
        override fun `as`(alias: Table<*>): CourseLibraryPath = CourseLibraryPath(alias.qualifiedName, this)
    }
    override fun getSchema(): Schema? = if (aliased()) null else Public.PUBLIC
    override fun getPrimaryKey(): UniqueKey<CourseLibraryRecord> = COURSE_LIBRARY_PKEY
    override fun getReferences(): List<ForeignKey<CourseLibraryRecord, *>> = listOf(COURSE_LIBRARY__COURSE_LIBRARY_COURSE_ID_FKEY, COURSE_LIBRARY__COURSE_LIBRARY_LIBRARY_ID_FKEY)

    private lateinit var _course: CoursePath

    /**
     * Get the implicit join path to the <code>public.course</code> table.
     */
    fun course(): CoursePath {
        if (!this::_course.isInitialized)
            _course = CoursePath(this, COURSE_LIBRARY__COURSE_LIBRARY_COURSE_ID_FKEY, null)

        return _course;
    }

    val course: CoursePath
        get(): CoursePath = course()

    private lateinit var _library: LibraryPath

    /**
     * Get the implicit join path to the <code>public.library</code> table.
     */
    fun library(): LibraryPath {
        if (!this::_library.isInitialized)
            _library = LibraryPath(this, COURSE_LIBRARY__COURSE_LIBRARY_LIBRARY_ID_FKEY, null)

        return _library;
    }

    val library: LibraryPath
        get(): LibraryPath = library()
    override fun `as`(alias: String): CourseLibrary = CourseLibrary(DSL.name(alias), this)
    override fun `as`(alias: Name): CourseLibrary = CourseLibrary(alias, this)
    override fun `as`(alias: Table<*>): CourseLibrary = CourseLibrary(alias.qualifiedName, this)

    /**
     * Rename this table
     */
    override fun rename(name: String): CourseLibrary = CourseLibrary(DSL.name(name), null)

    /**
     * Rename this table
     */
    override fun rename(name: Name): CourseLibrary = CourseLibrary(name, null)

    /**
     * Rename this table
     */
    override fun rename(name: Table<*>): CourseLibrary = CourseLibrary(name.qualifiedName, null)

    /**
     * Create an inline derived table from this table
     */
    override fun where(condition: Condition?): CourseLibrary = CourseLibrary(qualifiedName, if (aliased()) this else null, condition)

    /**
     * Create an inline derived table from this table
     */
    override fun where(conditions: Collection<Condition>): CourseLibrary = where(DSL.and(conditions))

    /**
     * Create an inline derived table from this table
     */
    override fun where(vararg conditions: Condition?): CourseLibrary = where(DSL.and(*conditions))

    /**
     * Create an inline derived table from this table
     */
    override fun where(condition: Field<Boolean?>?): CourseLibrary = where(DSL.condition(condition))

    /**
     * Create an inline derived table from this table
     */
    @PlainSQL override fun where(condition: SQL): CourseLibrary = where(DSL.condition(condition))

    /**
     * Create an inline derived table from this table
     */
    @PlainSQL override fun where(@Stringly.SQL condition: String): CourseLibrary = where(DSL.condition(condition))

    /**
     * Create an inline derived table from this table
     */
    @PlainSQL override fun where(@Stringly.SQL condition: String, vararg binds: Any?): CourseLibrary = where(DSL.condition(condition, *binds))

    /**
     * Create an inline derived table from this table
     */
    @PlainSQL override fun where(@Stringly.SQL condition: String, vararg parts: QueryPart): CourseLibrary = where(DSL.condition(condition, *parts))

    /**
     * Create an inline derived table from this table
     */
    override fun whereExists(select: Select<*>): CourseLibrary = where(DSL.exists(select))

    /**
     * Create an inline derived table from this table
     */
    override fun whereNotExists(select: Select<*>): CourseLibrary = where(DSL.notExists(select))
}
