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


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.journal_log.tables.UserInfo.UserInfoPath;
import ru.micord.webbpm.ervu.business_metrics.db_beans.journal_log.tables.UserOperation.UserOperationPath;
import ru.micord.webbpm.ervu.business_metrics.db_beans.journal_log.tables.UserWorkTime.UserWorkTimePath;
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.UsersRecord;


/**
 * Пользователи
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Users extends TableImpl<UsersRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>metrics.users</code>
     */
    public static final Users USERS = new Users();

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

    /**
     * The column <code>metrics.users.users_id</code>.
     */
    public final TableField<UsersRecord, Long> USERS_ID = createField(DSL.name("users_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

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

    /**
     * The column <code>metrics.users.start_date</code>.
     */
    public final TableField<UsersRecord, Timestamp> START_DATE = createField(DSL.name("start_date"), SQLDataType.TIMESTAMP(0).nullable(false).defaultValue(DSL.field(DSL.raw("now()"), SQLDataType.TIMESTAMP)), this, "");

    /**
     * The column <code>metrics.users.close_date</code>.
     */
    public final TableField<UsersRecord, Timestamp> CLOSE_DATE = createField(DSL.name("close_date"), SQLDataType.TIMESTAMP(0), this, "");

    /**
     * The column <code>metrics.users.user_login</code>.
     */
    public final TableField<UsersRecord, String> USER_LOGIN = createField(DSL.name("user_login"), SQLDataType.VARCHAR.nullable(false), this, "");

    /**
     * The column <code>metrics.users.user_secondname</code>.
     */
    public final TableField<UsersRecord, String> USER_SECONDNAME = createField(DSL.name("user_secondname"), SQLDataType.VARCHAR.nullable(false), this, "");

    /**
     * The column <code>metrics.users.user_firstname</code>.
     */
    public final TableField<UsersRecord, String> USER_FIRSTNAME = createField(DSL.name("user_firstname"), SQLDataType.VARCHAR.nullable(false), this, "");

    /**
     * The column <code>metrics.users.user_middlename</code>.
     */
    public final TableField<UsersRecord, String> USER_MIDDLENAME = createField(DSL.name("user_middlename"), SQLDataType.VARCHAR.nullable(false), this, "");

    /**
     * The column <code>metrics.users.user_fio</code>.
     */
    public final TableField<UsersRecord, String> USER_FIO = createField(DSL.name("user_fio"), SQLDataType.VARCHAR.nullable(false), this, "");

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

    private Users(Name alias, Table<UsersRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment("Пользователи"), TableOptions.table(), where);
    }

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

    /**
     * Create an aliased <code>metrics.users</code> table reference
     */
    public Users(Name alias) {
        this(alias, USERS);
    }

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

    public <O extends Record> Users(Table<O> path, ForeignKey<O, UsersRecord> childPath, InverseForeignKey<O, UsersRecord> parentPath) {
        super(path, childPath, parentPath, USERS);
    }

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

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

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

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

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

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

    @Override
    public UniqueKey<UsersRecord> getPrimaryKey() {
        return Keys.USERS_PKEY;
    }

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

        return _recruitment;
    }

    private transient UserInfoPath _userInfo;

    /**
     * Get the implicit to-many join path to the
     * <code>journal_log.user_info</code> table
     */
    public UserInfoPath userInfo() {
        if (_userInfo == null)
            _userInfo = new UserInfoPath(this, null, ru.micord.webbpm.ervu.business_metrics.db_beans.journal_log.Keys.USER_INFO__FK_USER_ID.getInverseKey());

        return _userInfo;
    }

    private transient UserOperationPath _userOperation;

    /**
     * Get the implicit to-many join path to the
     * <code>journal_log.user_operation</code> table
     */
    public UserOperationPath userOperation() {
        if (_userOperation == null)
            _userOperation = new UserOperationPath(this, null, ru.micord.webbpm.ervu.business_metrics.db_beans.journal_log.Keys.USER_OPERATION__FK_USER_ID.getInverseKey());

        return _userOperation;
    }

    private transient UserWorkTimePath _userWorkTime;

    /**
     * Get the implicit to-many join path to the
     * <code>journal_log.user_work_time</code> table
     */
    public UserWorkTimePath userWorkTime() {
        if (_userWorkTime == null)
            _userWorkTime = new UserWorkTimePath(this, null, ru.micord.webbpm.ervu.business_metrics.db_beans.journal_log.Keys.USER_WORK_TIME__FK_USER_ID.getInverseKey());

        return _userWorkTime;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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