/*
 * This file is generated by jOOQ.
 */
package org.jooq.meta.postgres.pg_catalog.tables;


import java.util.Arrays;
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.Record;
import org.jooq.Schema;
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 org.jooq.meta.postgres.pg_catalog.Keys;
import org.jooq.meta.postgres.pg_catalog.PgCatalog;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>pg_catalog.pg_enum</code>
     */
    public static final PgEnum PG_ENUM = new PgEnum();

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

    /**
     * The column <code>pg_catalog.pg_enum.oid</code>.
     */
    public final TableField<Record, Long> OID = createField(DSL.name("oid"), SQLDataType.BIGINT.nullable(false), this, "");

    /**
     * The column <code>pg_catalog.pg_enum.enumtypid</code>.
     */
    public final TableField<Record, Long> ENUMTYPID = createField(DSL.name("enumtypid"), SQLDataType.BIGINT.nullable(false), this, "");

    /**
     * The column <code>pg_catalog.pg_enum.enumsortorder</code>.
     */
    public final TableField<Record, Float> ENUMSORTORDER = createField(DSL.name("enumsortorder"), SQLDataType.REAL.nullable(false), this, "");

    /**
     * The column <code>pg_catalog.pg_enum.enumlabel</code>.
     */
    public final TableField<Record, String> ENUMLABEL = createField(DSL.name("enumlabel"), SQLDataType.VARCHAR.nullable(false), this, "");

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

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

    /**
     * Create an aliased <code>pg_catalog.pg_enum</code> table reference
     */
    public PgEnum(String alias) {
        this(DSL.name(alias), PG_ENUM);
    }

    /**
     * Create an aliased <code>pg_catalog.pg_enum</code> table reference
     */
    public PgEnum(Name alias) {
        this(alias, PG_ENUM);
    }

    /**
     * Create a <code>pg_catalog.pg_enum</code> table reference
     */
    public PgEnum() {
        this(DSL.name("pg_enum"), null);
    }

    public <O extends Record> PgEnum(Table<O> path, ForeignKey<O, Record> childPath, InverseForeignKey<O, Record> parentPath) {
        super(path, childPath, parentPath, PG_ENUM);
    }

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

    @Override
    public UniqueKey<Record> getPrimaryKey() {
        return Keys.PG_ENUM_OID_INDEX;
    }

    @Override
    public List<UniqueKey<Record>> getUniqueKeys() {
        return Arrays.asList(Keys.PG_ENUM_TYPID_LABEL_INDEX, Keys.PG_ENUM_TYPID_SORTORDER_INDEX);
    }

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

    private transient PgType _pgType;

    /**
     * Get the implicit join path to the <code>pg_catalog.pg_type</code> table.
     */
    public PgType pgType() {
        if (_pgType == null)
            _pgType = new PgType(this, Keys.PG_ENUM__SYNTHETIC_FK_PG_ENUM__SYNTHETIC_PK_PG_TYPE, null);

        return _pgType;
    }

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

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

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