/*
 * This file is generated by jOOQ.
 */
package jj.tech.paolu.repository.jooq.tables;


import java.util.function.Function;

import jj.tech.paolu.repository.jooq.Keys;
import jj.tech.paolu.repository.jooq.Yx;
import jj.tech.paolu.repository.jooq.tables.records.SysOrgRecord;

import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Function4;
import org.jooq.Name;
import org.jooq.Record;
import org.jooq.Records;
import org.jooq.Row4;
import org.jooq.Schema;
import org.jooq.SelectField;
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", "this-escape" })
public class SysOrg extends TableImpl<SysOrgRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>yx.sys_org</code>
     */
    public static final SysOrg SYS_ORG = new SysOrg();

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

    /**
     * The column <code>yx.sys_org.id</code>.
     */
    public final TableField<SysOrgRecord, String> ID = createField(DSL.name("id"), SQLDataType.VARCHAR(20).nullable(false), this, "");

    /**
     * The column <code>yx.sys_org.pid</code>.
     */
    public final TableField<SysOrgRecord, String> PID = createField(DSL.name("pid"), SQLDataType.VARCHAR(20).nullable(false), this, "");

    /**
     * The column <code>yx.sys_org.status</code>.
     */
    public final TableField<SysOrgRecord, Integer> STATUS = createField(DSL.name("status"), SQLDataType.INTEGER.defaultValue(DSL.field(DSL.raw("1"), SQLDataType.INTEGER)), this, "");

    /**
     * The column <code>yx.sys_org.org_type</code>.
     */
    public final TableField<SysOrgRecord, String> ORG_TYPE = createField(DSL.name("org_type"), SQLDataType.VARCHAR(20).defaultValue(DSL.field(DSL.raw("NULL"), SQLDataType.VARCHAR)), this, "");

    private SysOrg(Name alias, Table<SysOrgRecord> aliased) {
        this(alias, aliased, null);
    }

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

    /**
     * Create an aliased <code>yx.sys_org</code> table reference
     */
    public SysOrg(String alias) {
        this(DSL.name(alias), SYS_ORG);
    }

    /**
     * Create an aliased <code>yx.sys_org</code> table reference
     */
    public SysOrg(Name alias) {
        this(alias, SYS_ORG);
    }

    /**
     * Create a <code>yx.sys_org</code> table reference
     */
    public SysOrg() {
        this(DSL.name("sys_org"), null);
    }

    public <O extends Record> SysOrg(Table<O> child, ForeignKey<O, SysOrgRecord> key) {
        super(child, key, SYS_ORG);
    }

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

    @Override
    public UniqueKey<SysOrgRecord> getPrimaryKey() {
        return Keys.KEY_SYS_ORG_PRIMARY;
    }

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

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

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

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

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

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

    // -------------------------------------------------------------------------
    // Row4 type methods
    // -------------------------------------------------------------------------

    @Override
    public Row4<String, String, Integer, String> fieldsRow() {
        return (Row4) super.fieldsRow();
    }

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Function)}.
     */
    public <U> SelectField<U> mapping(Function4<? super String, ? super String, ? super Integer, ? super String, ? extends U> from) {
        return convertFrom(Records.mapping(from));
    }

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Class,
     * Function)}.
     */
    public <U> SelectField<U> mapping(Class<U> toType, Function4<? super String, ? super String, ? super Integer, ? super String, ? extends U> from) {
        return convertFrom(toType, Records.mapping(from));
    }
}
