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


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

import org.jooq.Check;
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;

import ru.micord.webbpm.ervu.business_metrics.db_beans.init_registration_info.InitRegistrationInfo;
import ru.micord.webbpm.ervu.business_metrics.db_beans.init_registration_info.Keys;
import ru.micord.webbpm.ervu.business_metrics.db_beans.init_registration_info.tables.records.CitizensNextYearAgeRecord;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables.Recruitment.RecruitmentPath;


/**
 * Первоначальная постановка на учет. Данные по количеству гражан на учете в 
 * возрасте 17 или 18 лет и по источнику самих данных
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class CitizensNextYearAge extends TableImpl<CitizensNextYearAgeRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>init_registration_info.citizens_next_year_age</code>
     */
    public static final CitizensNextYearAge CITIZENS_NEXT_YEAR_AGE = new CitizensNextYearAge();

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

    /**
     * The column
     * <code>init_registration_info.citizens_next_year_age.citizens_next_year_age_id</code>.
     */
    public final TableField<CitizensNextYearAgeRecord, Long> CITIZENS_NEXT_YEAR_AGE_ID = createField(DSL.name("citizens_next_year_age_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

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

    /**
     * The column
     * <code>init_registration_info.citizens_next_year_age.update_date</code>.
     */
    public final TableField<CitizensNextYearAgeRecord, 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>init_registration_info.citizens_next_year_age.info_date</code>.
     */
    public final TableField<CitizensNextYearAgeRecord, Date> INFO_DATE = createField(DSL.name("info_date"), SQLDataType.DATE.nullable(false), this, "");

    /**
     * The column
     * <code>init_registration_info.citizens_next_year_age.info_source</code>.
     * информация об источнике  - PERSONAL_VISIT, GIR_VU,  EPGU
     */
    public final TableField<CitizensNextYearAgeRecord, String> INFO_SOURCE = createField(DSL.name("info_source"), SQLDataType.VARCHAR.nullable(false), this, "информация об источнике  - PERSONAL_VISIT, GIR_VU,  EPGU");

    /**
     * The column
     * <code>init_registration_info.citizens_next_year_age.info_age</code>.
     * Информациия о каком возрасте 17_YEARS, 18_YEARS
     */
    public final TableField<CitizensNextYearAgeRecord, String> INFO_AGE = createField(DSL.name("info_age"), SQLDataType.VARCHAR.nullable(false), this, "Информациия о каком возрасте 17_YEARS, 18_YEARS");

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

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

    private CitizensNextYearAge(Name alias, Table<CitizensNextYearAgeRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment("Первоначальная постановка на учет. Данные по количеству гражан на учете в  возрасте 17 или 18 лет и по источнику самих данных"), TableOptions.table(), where);
    }

    /**
     * Create an aliased
     * <code>init_registration_info.citizens_next_year_age</code> table
     * reference
     */
    public CitizensNextYearAge(String alias) {
        this(DSL.name(alias), CITIZENS_NEXT_YEAR_AGE);
    }

    /**
     * Create an aliased
     * <code>init_registration_info.citizens_next_year_age</code> table
     * reference
     */
    public CitizensNextYearAge(Name alias) {
        this(alias, CITIZENS_NEXT_YEAR_AGE);
    }

    /**
     * Create a <code>init_registration_info.citizens_next_year_age</code> table
     * reference
     */
    public CitizensNextYearAge() {
        this(DSL.name("citizens_next_year_age"), null);
    }

    public <O extends Record> CitizensNextYearAge(Table<O> path, ForeignKey<O, CitizensNextYearAgeRecord> childPath, InverseForeignKey<O, CitizensNextYearAgeRecord> parentPath) {
        super(path, childPath, parentPath, CITIZENS_NEXT_YEAR_AGE);
    }

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

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

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

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

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

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

    @Override
    public UniqueKey<CitizensNextYearAgeRecord> getPrimaryKey() {
        return Keys.CITIZENS_NEXT_YEAR_AGE_PKEY;
    }

    @Override
    public List<ForeignKey<CitizensNextYearAgeRecord, ?>> getReferences() {
        return Arrays.asList(Keys.CITIZENS_NEXT_YEAR_AGE__FK_CONV_INFO_RECORDS_FROM_EASU_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.CITIZENS_NEXT_YEAR_AGE__FK_CONV_INFO_RECORDS_FROM_EASU_RECRUITMENT_ID, null);

        return _recruitment;
    }

    @Override
    public List<Check<CitizensNextYearAgeRecord>> getChecks() {
        return Arrays.asList(
            Internal.createCheck(this, DSL.name("chk_info_age"), "(((info_age)::text = ANY (ARRAY[('17_YEARS'::character varying)::text, ('18_YEARS'::character varying)::text, ('EPGU'::character varying)::text])))", true),
            Internal.createCheck(this, DSL.name("chk_info_source"), "(((info_source)::text = ANY (ARRAY[('PERSONAL_VISIT'::character varying)::text, ('GIR_VU'::character varying)::text, ('EPGU'::character varying)::text])))", true)
        );
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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