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


import jooq.main.Public
import jooq.main.keys.COMPANY_PKEY
import jooq.main.keys.VACANCY__VACANCY_COMPANY_ID_FKEY
import jooq.main.tables.Vacancy.VacancyPath
import jooq.main.tables.records.CompanyRecord

import kotlin.collections.Collection

import org.jooq.Condition
import org.jooq.Field
import org.jooq.ForeignKey
import org.jooq.Identity
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 Company(
    alias: Name,
    path: Table<out Record>?,
    childPath: ForeignKey<out Record, CompanyRecord>?,
    parentPath: InverseForeignKey<out Record, CompanyRecord>?,
    aliased: Table<CompanyRecord>?,
    parameters: Array<Field<*>?>?,
    where: Condition?
): TableImpl<CompanyRecord>(
    alias,
    Public.PUBLIC,
    path,
    childPath,
    parentPath,
    aliased,
    parameters,
    DSL.comment(""),
    TableOptions.table(),
    where,
) {
    companion object {

        /**
         * The reference instance of <code>public.company</code>
         */
        val COMPANY: Company = Company()
    }

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

    /**
     * The column <code>public.company.id</code>.
     */
    val ID: TableField<CompanyRecord, Long?> = createField(DSL.name("id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "")

    /**
     * The column <code>public.company.name</code>.
     */
    val NAME: TableField<CompanyRecord, String?> = createField(DSL.name("name"), SQLDataType.VARCHAR(500).nullable(false), this, "")

    /**
     * The column <code>public.company.description</code>.
     */
    val DESCRIPTION: TableField<CompanyRecord, String?> = createField(DSL.name("description"), SQLDataType.CLOB.nullable(false), this, "")

    /**
     * The column <code>public.company.url</code>.
     */
    val URL: TableField<CompanyRecord, String?> = createField(DSL.name("url"), SQLDataType.VARCHAR(500).nullable(false), this, "")

    /**
     * The column <code>public.company.logo</code>.
     */
    val LOGO: TableField<CompanyRecord, String?> = createField(DSL.name("logo"), SQLDataType.VARCHAR(500).nullable(false), this, "")

    /**
     * The column <code>public.company.version</code>.
     */
    val VERSION: TableField<CompanyRecord, Long?> = createField(DSL.name("version"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "")

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

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

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

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

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

    /**
     * A subtype implementing {@link Path} for simplified path-based joins.
     */
    open class CompanyPath : Company, Path<CompanyRecord> {
        constructor(path: Table<out Record>, childPath: ForeignKey<out Record, CompanyRecord>?, parentPath: InverseForeignKey<out Record, CompanyRecord>?): super(path, childPath, parentPath)
        private constructor(alias: Name, aliased: Table<CompanyRecord>): super(alias, aliased)
        override fun `as`(alias: String): CompanyPath = CompanyPath(DSL.name(alias), this)
        override fun `as`(alias: Name): CompanyPath = CompanyPath(alias, this)
        override fun `as`(alias: Table<*>): CompanyPath = CompanyPath(alias.qualifiedName, this)
    }
    override fun getSchema(): Schema? = if (aliased()) null else Public.PUBLIC
    override fun getIdentity(): Identity<CompanyRecord, Long?> = super.getIdentity() as Identity<CompanyRecord, Long?>
    override fun getPrimaryKey(): UniqueKey<CompanyRecord> = COMPANY_PKEY

    private lateinit var _vacancy: VacancyPath

    /**
     * Get the implicit to-many join path to the <code>public.vacancy</code>
     * table
     */
    fun vacancy(): VacancyPath {
        if (!this::_vacancy.isInitialized)
            _vacancy = VacancyPath(this, null, VACANCY__VACANCY_COMPANY_ID_FKEY.inverseKey)

        return _vacancy;
    }

    val vacancy: VacancyPath
        get(): VacancyPath = vacancy()
    override fun `as`(alias: String): Company = Company(DSL.name(alias), this)
    override fun `as`(alias: Name): Company = Company(alias, this)
    override fun `as`(alias: Table<*>): Company = Company(alias.qualifiedName, this)

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

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

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

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

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

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

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

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

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

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

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

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

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