/*
 * This file is generated by jOOQ.
 */
package ervu_dashboard.ervu_dashboard.db_beans.security.tables;


import ervu_dashboard.ervu_dashboard.db_beans.security.Keys;
import ervu_dashboard.ervu_dashboard.db_beans.security.Security;
import ervu_dashboard.ervu_dashboard.db_beans.security.tables.OrgUnit.OrgUnitPath;
import ervu_dashboard.ervu_dashboard.db_beans.security.tables.UserAccount.UserAccountPath;
import ervu_dashboard.ervu_dashboard.db_beans.security.tables.records.OrgUnitRecord;

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.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;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>security.org_unit</code>
     */
    public static final OrgUnit ORG_UNIT = new OrgUnit();

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

    /**
     * The column <code>security.org_unit.id</code>.
     */
    public final TableField<OrgUnitRecord, String> ID = createField(DSL.name("id"), SQLDataType.CHAR(36).nullable(false), this, "");

    /**
     * The column <code>security.org_unit.name</code>.
     */
    public final TableField<OrgUnitRecord, String> NAME = createField(DSL.name("name"), SQLDataType.VARCHAR(1000).nullable(false), this, "");

    /**
     * The column <code>security.org_unit.code</code>.
     */
    public final TableField<OrgUnitRecord, String> CODE = createField(DSL.name("code"), SQLDataType.VARCHAR(50).nullable(false), this, "");

    /**
     * The column <code>security.org_unit.parent_id</code>.
     */
    public final TableField<OrgUnitRecord, String> PARENT_ID = createField(DSL.name("parent_id"), SQLDataType.CHAR(36), this, "");

    /**
     * The column <code>security.org_unit.removed</code>.
     */
    public final TableField<OrgUnitRecord, Boolean> REMOVED = createField(DSL.name("removed"), SQLDataType.BOOLEAN.nullable(false).defaultValue(DSL.field(DSL.raw("false"), SQLDataType.BOOLEAN)), this, "");

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

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

    /**
     * Create an aliased <code>security.org_unit</code> table reference
     */
    public OrgUnit(String alias) {
        this(DSL.name(alias), ORG_UNIT);
    }

    /**
     * Create an aliased <code>security.org_unit</code> table reference
     */
    public OrgUnit(Name alias) {
        this(alias, ORG_UNIT);
    }

    /**
     * Create a <code>security.org_unit</code> table reference
     */
    public OrgUnit() {
        this(DSL.name("org_unit"), null);
    }

    public <O extends Record> OrgUnit(Table<O> path, ForeignKey<O, OrgUnitRecord> childPath, InverseForeignKey<O, OrgUnitRecord> parentPath) {
        super(path, childPath, parentPath, ORG_UNIT);
    }

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

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

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

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

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

    @Override
    public UniqueKey<OrgUnitRecord> getPrimaryKey() {
        return Keys.PK_ORG_UNIT;
    }

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

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

    private transient OrgUnitPath _orgUnit;

    /**
     * Get the implicit join path to the <code>security.org_unit</code> table.
     */
    public OrgUnitPath orgUnit() {
        if (_orgUnit == null)
            _orgUnit = new OrgUnitPath(this, Keys.ORG_UNIT__FK_ORG_UNIT_PARENT_ID, null);

        return _orgUnit;
    }

    private transient UserAccountPath _userAccount;

    /**
     * Get the implicit to-many join path to the
     * <code>security.user_account</code> table
     */
    public UserAccountPath userAccount() {
        if (_userAccount == null)
            _userAccount = new UserAccountPath(this, null, Keys.USER_ACCOUNT__FK_USER_ORG_UNIT_ID.getInverseKey());

        return _userAccount;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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