/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.actualization.tables;


import java.sql.Date;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

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.SQLDataType;
import org.jooq.impl.TableImpl;

import ru.micord.webbpm.ervu.business_metrics.db_beans.actualization.Actualization;
import ru.micord.webbpm.ervu.business_metrics.db_beans.actualization.Keys;
import ru.micord.webbpm.ervu.business_metrics.db_beans.actualization.tables.records.AppReasonRecord;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables.Recruitment.RecruitmentPath;


/**
 * Актуализация. Причины заявлений
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class AppReason extends TableImpl<AppReasonRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>actualization.app_reason</code>
     */
    public static final AppReason APP_REASON = new AppReason();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<AppReasonRecord> getRecordType() {
        return AppReasonRecord.class;
    }

    /**
     * The column <code>actualization.app_reason.app_reason_id</code>.
     */
    public final TableField<AppReasonRecord, Long> APP_REASON_ID = createField(DSL.name("app_reason_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

    /**
     * The column <code>actualization.app_reason.recruitment_id</code>.
     */
    public final TableField<AppReasonRecord, String> RECRUITMENT_ID = createField(DSL.name("recruitment_id"), SQLDataType.VARCHAR(36).nullable(false), this, "");

    /**
     * The column <code>actualization.app_reason.update_date</code>.
     */
    public final TableField<AppReasonRecord, Timestamp> UPDATE_DATE = createField(DSL.name("update_date"), SQLDataType.TIMESTAMP(0).nullable(false).defaultValue(DSL.field(DSL.raw("now()"), SQLDataType.TIMESTAMP)), this, "");

    /**
     * The column <code>actualization.app_reason.info_date</code>.
     */
    public final TableField<AppReasonRecord, Date> INFO_DATE = createField(DSL.name("info_date"), SQLDataType.DATE.nullable(false), this, "");

    /**
     * The column <code>actualization.app_reason.count_place_of_stay</code>.
     */
    public final TableField<AppReasonRecord, Long> COUNT_PLACE_OF_STAY = createField(DSL.name("count_place_of_stay"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "");

    /**
     * The column <code>actualization.app_reason.count_work</code>.
     */
    public final TableField<AppReasonRecord, Long> COUNT_WORK = createField(DSL.name("count_work"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "");

    /**
     * The column <code>actualization.app_reason.count_place_of_study</code>.
     */
    public final TableField<AppReasonRecord, Long> COUNT_PLACE_OF_STUDY = createField(DSL.name("count_place_of_study"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "");

    /**
     * The column <code>actualization.app_reason.count_family_status</code>.
     */
    public final TableField<AppReasonRecord, Long> COUNT_FAMILY_STATUS = createField(DSL.name("count_family_status"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "");

    /**
     * The column <code>actualization.app_reason.count_education</code>.
     */
    public final TableField<AppReasonRecord, Long> COUNT_EDUCATION = createField(DSL.name("count_education"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "");

    /**
     * The column <code>actualization.app_reason.count_renaming</code>.
     */
    public final TableField<AppReasonRecord, Long> COUNT_RENAMING = createField(DSL.name("count_renaming"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "");

    /**
     * The column <code>actualization.app_reason.count_all</code>.
     */
    public final TableField<AppReasonRecord, Long> COUNT_ALL = createField(DSL.name("count_all"), SQLDataType.BIGINT.nullable(false).defaultValue(DSL.field(DSL.raw("0"), SQLDataType.BIGINT)), this, "");

    private AppReason(Name alias, Table<AppReasonRecord> aliased) {
        this(alias, aliased, (Field<?>[]) null, null);
    }

    private AppReason(Name alias, Table<AppReasonRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment("Актуализация. Причины заявлений"), TableOptions.table(), where);
    }

    /**
     * Create an aliased <code>actualization.app_reason</code> table reference
     */
    public AppReason(String alias) {
        this(DSL.name(alias), APP_REASON);
    }

    /**
     * Create an aliased <code>actualization.app_reason</code> table reference
     */
    public AppReason(Name alias) {
        this(alias, APP_REASON);
    }

    /**
     * Create a <code>actualization.app_reason</code> table reference
     */
    public AppReason() {
        this(DSL.name("app_reason"), null);
    }

    public <O extends Record> AppReason(Table<O> path, ForeignKey<O, AppReasonRecord> childPath, InverseForeignKey<O, AppReasonRecord> parentPath) {
        super(path, childPath, parentPath, APP_REASON);
    }

    /**
     * A subtype implementing {@link Path} for simplified path-based joins.
     */
    public static class AppReasonPath extends AppReason implements Path<AppReasonRecord> {
        public <O extends Record> AppReasonPath(Table<O> path, ForeignKey<O, AppReasonRecord> childPath, InverseForeignKey<O, AppReasonRecord> parentPath) {
            super(path, childPath, parentPath);
        }
        private AppReasonPath(Name alias, Table<AppReasonRecord> aliased) {
            super(alias, aliased);
        }

        @Override
        public AppReasonPath as(String alias) {
            return new AppReasonPath(DSL.name(alias), this);
        }

        @Override
        public AppReasonPath as(Name alias) {
            return new AppReasonPath(alias, this);
        }

        @Override
        public AppReasonPath as(Table<?> alias) {
            return new AppReasonPath(alias.getQualifiedName(), this);
        }
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : Actualization.ACTUALIZATION;
    }

    @Override
    public Identity<AppReasonRecord, Long> getIdentity() {
        return (Identity<AppReasonRecord, Long>) super.getIdentity();
    }

    @Override
    public UniqueKey<AppReasonRecord> getPrimaryKey() {
        return Keys.APP_REASON_PKEY;
    }

    @Override
    public List<ForeignKey<AppReasonRecord, ?>> getReferences() {
        return Arrays.asList(Keys.APP_REASON__FK_CRIMINAL_ADMINISTRATIVE_LIABILITY_RECRUITMENT_ID);
    }

    private transient RecruitmentPath _recruitment;

    /**
     * Get the implicit join path to the <code>metrics.recruitment</code> table.
     */
    public RecruitmentPath recruitment() {
        if (_recruitment == null)
            _recruitment = new RecruitmentPath(this, Keys.APP_REASON__FK_CRIMINAL_ADMINISTRATIVE_LIABILITY_RECRUITMENT_ID, null);

        return _recruitment;
    }

    @Override
    public AppReason as(String alias) {
        return new AppReason(DSL.name(alias), this);
    }

    @Override
    public AppReason as(Name alias) {
        return new AppReason(alias, this);
    }

    @Override
    public AppReason as(Table<?> alias) {
        return new AppReason(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public AppReason rename(String name) {
        return new AppReason(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public AppReason rename(Name name) {
        return new AppReason(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public AppReason rename(Table<?> name) {
        return new AppReason(name.getQualifiedName(), null);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public AppReason where(Condition condition) {
        return new AppReason(getQualifiedName(), aliased() ? this : null, null, condition);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public AppReason where(Collection<? extends Condition> conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public AppReason where(Condition... conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public AppReason where(Field<Boolean> condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public AppReason where(SQL condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public AppReason where(@Stringly.SQL String condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public AppReason where(@Stringly.SQL String condition, Object... binds) {
        return where(DSL.condition(condition, binds));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public AppReason where(@Stringly.SQL String condition, QueryPart... parts) {
        return where(DSL.condition(condition, parts));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public AppReason whereExists(Select<?> select) {
        return where(DSL.exists(select));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public AppReason whereNotExists(Select<?> select) {
        return where(DSL.notExists(select));
    }
}
