/*
 * 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.Authority.AuthorityPath;
import ervu_dashboard.ervu_dashboard.db_beans.security.tables.LinkUserGroupUserRole.LinkUserGroupUserRolePath;
import ervu_dashboard.ervu_dashboard.db_beans.security.tables.LinkUserRoleAuthority.LinkUserRoleAuthorityPath;
import ervu_dashboard.ervu_dashboard.db_beans.security.tables.UserGroup.UserGroupPath;
import ervu_dashboard.ervu_dashboard.db_beans.security.tables.records.UserRoleRecord;

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.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 UserRole extends TableImpl<UserRoleRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>security.user_role</code>
     */
    public static final UserRole USER_ROLE = new UserRole();

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

    /**
     * The column <code>security.user_role.user_role_id</code>.
     */
    public final TableField<UserRoleRecord, String> USER_ROLE_ID = createField(DSL.name("user_role_id"), SQLDataType.CHAR(36).nullable(false), this, "");

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

    /**
     * The column <code>security.user_role.created</code>.
     */
    public final TableField<UserRoleRecord, Timestamp> CREATED = createField(DSL.name("created"), SQLDataType.TIMESTAMP(0).nullable(false).defaultValue(DSL.field(DSL.raw("now()"), SQLDataType.TIMESTAMP)), this, "");

    /**
     * The column <code>security.user_role.updated</code>.
     */
    public final TableField<UserRoleRecord, Timestamp> UPDATED = createField(DSL.name("updated"), SQLDataType.TIMESTAMP(0).nullable(false).defaultValue(DSL.field(DSL.raw("now()"), SQLDataType.TIMESTAMP)), this, "");

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

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

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

    /**
     * Create an aliased <code>security.user_role</code> table reference
     */
    public UserRole(Name alias) {
        this(alias, USER_ROLE);
    }

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

    public <O extends Record> UserRole(Table<O> path, ForeignKey<O, UserRoleRecord> childPath, InverseForeignKey<O, UserRoleRecord> parentPath) {
        super(path, childPath, parentPath, USER_ROLE);
    }

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

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

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

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

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

    @Override
    public UniqueKey<UserRoleRecord> getPrimaryKey() {
        return Keys.PK_ROLE;
    }

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

    private transient LinkUserGroupUserRolePath _linkUserGroupUserRole;

    /**
     * Get the implicit to-many join path to the
     * <code>security.link_user_group_user_role</code> table
     */
    public LinkUserGroupUserRolePath linkUserGroupUserRole() {
        if (_linkUserGroupUserRole == null)
            _linkUserGroupUserRole = new LinkUserGroupUserRolePath(this, null, Keys.LINK_USER_GROUP_USER_ROLE__FK_GROUP_ROLE_ROLE.getInverseKey());

        return _linkUserGroupUserRole;
    }

    private transient LinkUserRoleAuthorityPath _linkUserRoleAuthority;

    /**
     * Get the implicit to-many join path to the
     * <code>security.link_user_role_authority</code> table
     */
    public LinkUserRoleAuthorityPath linkUserRoleAuthority() {
        if (_linkUserRoleAuthority == null)
            _linkUserRoleAuthority = new LinkUserRoleAuthorityPath(this, null, Keys.LINK_USER_ROLE_AUTHORITY__FK_ROLE_AUTHORITY_ROLE.getInverseKey());

        return _linkUserRoleAuthority;
    }

    /**
     * Get the implicit many-to-many join path to the
     * <code>security.user_group</code> table
     */
    public UserGroupPath userGroup() {
        return linkUserGroupUserRole().userGroup();
    }

    /**
     * Get the implicit many-to-many join path to the
     * <code>security.authority</code> table
     */
    public AuthorityPath authority() {
        return linkUserRoleAuthority().authority();
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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