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


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.metrics.Keys;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.Metrics;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables.Recruitment.RecruitmentPath;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables.records.RegionRecord;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Region extends TableImpl<RegionRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>metrics.region</code>
     */
    public static final Region REGION = new Region();

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

    /**
     * The column <code>metrics.region.region_id</code>.
     */
    public final TableField<RegionRecord, Integer> REGION_ID = createField(DSL.name("region_id"), SQLDataType.INTEGER.nullable(false).identity(true), this, "");

    /**
     * The column <code>metrics.region.subject_code</code>.
     */
    public final TableField<RegionRecord, String> SUBJECT_CODE = createField(DSL.name("subject_code"), SQLDataType.VARCHAR(3).nullable(false), this, "");

    /**
     * The column <code>metrics.region.subject_name</code>.
     */
    public final TableField<RegionRecord, String> SUBJECT_NAME = createField(DSL.name("subject_name"), SQLDataType.VARCHAR(150).nullable(false), this, "");

    /**
     * The column <code>metrics.region.subject_codename</code>.
     */
    public final TableField<RegionRecord, String> SUBJECT_CODENAME = createField(DSL.name("subject_codename"), SQLDataType.VARCHAR(200).nullable(false), this, "");

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

    private Region(Name alias, Table<RegionRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table(), where);
    }

    /**
     * Create an aliased <code>metrics.region</code> table reference
     */
    public Region(String alias) {
        this(DSL.name(alias), REGION);
    }

    /**
     * Create an aliased <code>metrics.region</code> table reference
     */
    public Region(Name alias) {
        this(alias, REGION);
    }

    /**
     * Create a <code>metrics.region</code> table reference
     */
    public Region() {
        this(DSL.name("region"), null);
    }

    public <O extends Record> Region(Table<O> path, ForeignKey<O, RegionRecord> childPath, InverseForeignKey<O, RegionRecord> parentPath) {
        super(path, childPath, parentPath, REGION);
    }

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

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

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

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

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

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

    @Override
    public UniqueKey<RegionRecord> getPrimaryKey() {
        return Keys.REGION_PKEY;
    }

    @Override
    public List<UniqueKey<RegionRecord>> getUniqueKeys() {
        return Arrays.asList(Keys.UNI_REGION1);
    }

    private transient RecruitmentPath _recruitment;

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

        return _recruitment;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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