/*
 * This file is generated by jOOQ.
 */
package ervu_secret.ervu_secret.db_beans.information_schema.tables;


import ervu_secret.ervu_secret.db_beans.information_schema.Domains;
import ervu_secret.ervu_secret.db_beans.information_schema.InformationSchema;
import ervu_secret.ervu_secret.db_beans.information_schema.tables.records.SequencesRecord;

import java.util.Collection;

import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.PlainSQL;
import org.jooq.QueryPart;
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.impl.DSL;
import org.jooq.impl.TableImpl;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>information_schema.sequences</code>
     */
    public static final Sequences SEQUENCES = new Sequences();

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

    /**
     * The column <code>information_schema.sequences.sequence_catalog</code>.
     */
    public final TableField<SequencesRecord, String> SEQUENCE_CATALOG = createField(DSL.name("sequence_catalog"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column <code>information_schema.sequences.sequence_schema</code>.
     */
    public final TableField<SequencesRecord, String> SEQUENCE_SCHEMA = createField(DSL.name("sequence_schema"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column <code>information_schema.sequences.sequence_name</code>.
     */
    public final TableField<SequencesRecord, String> SEQUENCE_NAME = createField(DSL.name("sequence_name"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column <code>information_schema.sequences.data_type</code>.
     */
    public final TableField<SequencesRecord, String> DATA_TYPE = createField(DSL.name("data_type"), Domains.CHARACTER_DATA.getDataType(), this, "");

    /**
     * The column <code>information_schema.sequences.numeric_precision</code>.
     */
    public final TableField<SequencesRecord, Integer> NUMERIC_PRECISION = createField(DSL.name("numeric_precision"), Domains.CARDINAL_NUMBER.getDataType(), this, "");

    /**
     * The column
     * <code>information_schema.sequences.numeric_precision_radix</code>.
     */
    public final TableField<SequencesRecord, Integer> NUMERIC_PRECISION_RADIX = createField(DSL.name("numeric_precision_radix"), Domains.CARDINAL_NUMBER.getDataType(), this, "");

    /**
     * The column <code>information_schema.sequences.numeric_scale</code>.
     */
    public final TableField<SequencesRecord, Integer> NUMERIC_SCALE = createField(DSL.name("numeric_scale"), Domains.CARDINAL_NUMBER.getDataType(), this, "");

    /**
     * The column <code>information_schema.sequences.start_value</code>.
     */
    public final TableField<SequencesRecord, String> START_VALUE = createField(DSL.name("start_value"), Domains.CHARACTER_DATA.getDataType(), this, "");

    /**
     * The column <code>information_schema.sequences.minimum_value</code>.
     */
    public final TableField<SequencesRecord, String> MINIMUM_VALUE = createField(DSL.name("minimum_value"), Domains.CHARACTER_DATA.getDataType(), this, "");

    /**
     * The column <code>information_schema.sequences.maximum_value</code>.
     */
    public final TableField<SequencesRecord, String> MAXIMUM_VALUE = createField(DSL.name("maximum_value"), Domains.CHARACTER_DATA.getDataType(), this, "");

    /**
     * The column <code>information_schema.sequences.increment</code>.
     */
    public final TableField<SequencesRecord, String> INCREMENT = createField(DSL.name("increment"), Domains.CHARACTER_DATA.getDataType(), this, "");

    /**
     * The column <code>information_schema.sequences.cycle_option</code>.
     */
    public final TableField<SequencesRecord, String> CYCLE_OPTION = createField(DSL.name("cycle_option"), Domains.YES_OR_NO.getDataType(), this, "");

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

    private Sequences(Name alias, Table<SequencesRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "sequences" as  SELECT (current_database())::information_schema.sql_identifier AS sequence_catalog,
          (nc.nspname)::information_schema.sql_identifier AS sequence_schema,
          (c.relname)::information_schema.sql_identifier AS sequence_name,
          (format_type(s.seqtypid, NULL::integer))::information_schema.character_data AS data_type,
          (information_schema._pg_numeric_precision(s.seqtypid, '-1'::integer))::information_schema.cardinal_number AS numeric_precision,
          (2)::information_schema.cardinal_number AS numeric_precision_radix,
          (0)::information_schema.cardinal_number AS numeric_scale,
          (s.seqstart)::information_schema.character_data AS start_value,
          (s.seqmin)::information_schema.character_data AS minimum_value,
          (s.seqmax)::information_schema.character_data AS maximum_value,
          (s.seqincrement)::information_schema.character_data AS increment,
          (
              CASE
                  WHEN s.seqcycle THEN 'YES'::text
                  ELSE 'NO'::text
              END)::information_schema.yes_or_no AS cycle_option
         FROM pg_namespace nc,
          pg_class c,
          pg_sequence s
        WHERE ((c.relnamespace = nc.oid) AND (c.relkind = 'S'::"char") AND (NOT (EXISTS ( SELECT 1
                 FROM pg_depend
                WHERE ((pg_depend.classid = ('pg_class'::regclass)::oid) AND (pg_depend.objid = c.oid) AND (pg_depend.deptype = 'i'::"char"))))) AND (NOT pg_is_other_temp_schema(nc.oid)) AND (c.oid = s.seqrelid) AND (pg_has_role(c.relowner, 'USAGE'::text) OR has_sequence_privilege(c.oid, 'SELECT, UPDATE, USAGE'::text)));
        """), where);
    }

    /**
     * Create an aliased <code>information_schema.sequences</code> table
     * reference
     */
    public Sequences(String alias) {
        this(DSL.name(alias), SEQUENCES);
    }

    /**
     * Create an aliased <code>information_schema.sequences</code> table
     * reference
     */
    public Sequences(Name alias) {
        this(alias, SEQUENCES);
    }

    /**
     * Create a <code>information_schema.sequences</code> table reference
     */
    public Sequences() {
        this(DSL.name("sequences"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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