/*
 * This file is generated by jOOQ.
 */
package ru.micord.ervu_dashboard.db_beans.ervu_dashboard.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.ervu_dashboard.db_beans.ervu_dashboard.ErvuDashboard;
import ru.micord.ervu_dashboard.db_beans.ervu_dashboard.Keys;
import ru.micord.ervu_dashboard.db_beans.ervu_dashboard.tables.CitizenDeferment.CitizenDefermentPath;
import ru.micord.ervu_dashboard.db_beans.ervu_dashboard.tables.CitizenDefermentRight.CitizenDefermentRightPath;
import ru.micord.ervu_dashboard.db_beans.ervu_dashboard.tables.records.DefermentReasonRecord;


/**
 * Справчоник причин для отсрочки/освобождения от службы
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class DefermentReason extends TableImpl<DefermentReasonRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>ervu_dashboard.deferment_reason</code>
     */
    public static final DefermentReason DEFERMENT_REASON = new DefermentReason();

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

    /**
     * The column
     * <code>ervu_dashboard.deferment_reason.deferment_reason_id</code>.
     */
    public final TableField<DefermentReasonRecord, Long> DEFERMENT_REASON_ID = createField(DSL.name("deferment_reason_id"), SQLDataType.BIGINT.nullable(false).identity(true), this, "");

    /**
     * The column <code>ervu_dashboard.deferment_reason.code</code>. Cправочный
     * код причины
     */
    public final TableField<DefermentReasonRecord, String> CODE = createField(DSL.name("code"), SQLDataType.VARCHAR(15).nullable(false), this, "Cправочный код причины");

    /**
     * The column <code>ervu_dashboard.deferment_reason.value</code>. Причина
     * отсрочки/освобождения
     */
    public final TableField<DefermentReasonRecord, String> VALUE = createField(DSL.name("value"), SQLDataType.VARCHAR(255).nullable(false), this, "Причина отсрочки/освобождения");

    /**
     * The column <code>ervu_dashboard.deferment_reason.actual</code>. Признак
     * актуальности справочного значения
     */
    public final TableField<DefermentReasonRecord, Boolean> ACTUAL = createField(DSL.name("actual"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.field(DSL.raw("true"), SQLDataType.BOOLEAN)), this, "Признак актуальности справочного значения");

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

    private DefermentReason(Name alias, Table<DefermentReasonRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment("Справчоник причин для отсрочки/освобождения от службы"), TableOptions.table(), where);
    }

    /**
     * Create an aliased <code>ervu_dashboard.deferment_reason</code> table
     * reference
     */
    public DefermentReason(String alias) {
        this(DSL.name(alias), DEFERMENT_REASON);
    }

    /**
     * Create an aliased <code>ervu_dashboard.deferment_reason</code> table
     * reference
     */
    public DefermentReason(Name alias) {
        this(alias, DEFERMENT_REASON);
    }

    /**
     * Create a <code>ervu_dashboard.deferment_reason</code> table reference
     */
    public DefermentReason() {
        this(DSL.name("deferment_reason"), null);
    }

    public <O extends Record> DefermentReason(Table<O> path, ForeignKey<O, DefermentReasonRecord> childPath, InverseForeignKey<O, DefermentReasonRecord> parentPath) {
        super(path, childPath, parentPath, DEFERMENT_REASON);
    }

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

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

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

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

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

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

    @Override
    public UniqueKey<DefermentReasonRecord> getPrimaryKey() {
        return Keys.DEFERMENT_REASON_PKEY;
    }

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

    private transient CitizenDefermentPath _citizenDeferment;

    /**
     * Get the implicit to-many join path to the
     * <code>ervu_dashboard.citizen_deferment</code> table
     */
    public CitizenDefermentPath citizenDeferment() {
        if (_citizenDeferment == null)
            _citizenDeferment = new CitizenDefermentPath(this, null, Keys.CITIZEN_DEFERMENT__CITIZEN_DEFERMENT_DEFERMENT_REASON_CODE_FK.getInverseKey());

        return _citizenDeferment;
    }

    private transient CitizenDefermentRightPath _citizenDefermentRight;

    /**
     * Get the implicit to-many join path to the
     * <code>ervu_dashboard.citizen_deferment_right</code> table
     */
    public CitizenDefermentRightPath citizenDefermentRight() {
        if (_citizenDefermentRight == null)
            _citizenDefermentRight = new CitizenDefermentRightPath(this, null, Keys.CITIZEN_DEFERMENT_RIGHT__CITIZEN_DEFERMENT_RIGHT_DEFERMENT_REASON_CODE_FK.getInverseKey());

        return _citizenDefermentRight;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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