/*
 * 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.TriggersRecord;

import java.sql.Timestamp;
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.SQLDataType;
import org.jooq.impl.TableImpl;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>information_schema.triggers</code>
     */
    public static final Triggers TRIGGERS = new Triggers();

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

    /**
     * The column <code>information_schema.triggers.trigger_catalog</code>.
     */
    public final TableField<TriggersRecord, String> TRIGGER_CATALOG = createField(DSL.name("trigger_catalog"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.trigger_schema</code>.
     */
    public final TableField<TriggersRecord, String> TRIGGER_SCHEMA = createField(DSL.name("trigger_schema"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.trigger_name</code>.
     */
    public final TableField<TriggersRecord, String> TRIGGER_NAME = createField(DSL.name("trigger_name"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.event_manipulation</code>.
     */
    public final TableField<TriggersRecord, String> EVENT_MANIPULATION = createField(DSL.name("event_manipulation"), Domains.CHARACTER_DATA.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.event_object_catalog</code>.
     */
    public final TableField<TriggersRecord, String> EVENT_OBJECT_CATALOG = createField(DSL.name("event_object_catalog"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.event_object_schema</code>.
     */
    public final TableField<TriggersRecord, String> EVENT_OBJECT_SCHEMA = createField(DSL.name("event_object_schema"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.event_object_table</code>.
     */
    public final TableField<TriggersRecord, String> EVENT_OBJECT_TABLE = createField(DSL.name("event_object_table"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.action_order</code>.
     */
    public final TableField<TriggersRecord, Integer> ACTION_ORDER = createField(DSL.name("action_order"), Domains.CARDINAL_NUMBER.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.action_condition</code>.
     */
    public final TableField<TriggersRecord, String> ACTION_CONDITION = createField(DSL.name("action_condition"), Domains.CHARACTER_DATA.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.action_statement</code>.
     */
    public final TableField<TriggersRecord, String> ACTION_STATEMENT = createField(DSL.name("action_statement"), Domains.CHARACTER_DATA.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.action_orientation</code>.
     */
    public final TableField<TriggersRecord, String> ACTION_ORIENTATION = createField(DSL.name("action_orientation"), Domains.CHARACTER_DATA.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.action_timing</code>.
     */
    public final TableField<TriggersRecord, String> ACTION_TIMING = createField(DSL.name("action_timing"), Domains.CHARACTER_DATA.getDataType(), this, "");

    /**
     * The column
     * <code>information_schema.triggers.action_reference_old_table</code>.
     */
    public final TableField<TriggersRecord, String> ACTION_REFERENCE_OLD_TABLE = createField(DSL.name("action_reference_old_table"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column
     * <code>information_schema.triggers.action_reference_new_table</code>.
     */
    public final TableField<TriggersRecord, String> ACTION_REFERENCE_NEW_TABLE = createField(DSL.name("action_reference_new_table"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column
     * <code>information_schema.triggers.action_reference_old_row</code>.
     */
    public final TableField<TriggersRecord, String> ACTION_REFERENCE_OLD_ROW = createField(DSL.name("action_reference_old_row"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column
     * <code>information_schema.triggers.action_reference_new_row</code>.
     */
    public final TableField<TriggersRecord, String> ACTION_REFERENCE_NEW_ROW = createField(DSL.name("action_reference_new_row"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column <code>information_schema.triggers.created</code>.
     */
    public final TableField<TriggersRecord, Timestamp> CREATED = createField(DSL.name("created"), SQLDataType.TIMESTAMP(0), this, "");

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

    private Triggers(Name alias, Table<TriggersRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "triggers" as  SELECT (current_database())::information_schema.sql_identifier AS trigger_catalog,
          (n.nspname)::information_schema.sql_identifier AS trigger_schema,
          (t.tgname)::information_schema.sql_identifier AS trigger_name,
          (em.text)::information_schema.character_data AS event_manipulation,
          (current_database())::information_schema.sql_identifier AS event_object_catalog,
          (n.nspname)::information_schema.sql_identifier AS event_object_schema,
          (c.relname)::information_schema.sql_identifier AS event_object_table,
          (rank() OVER (PARTITION BY (n.nspname)::information_schema.sql_identifier, (c.relname)::information_schema.sql_identifier, em.num, ((t.tgtype)::integer & 1), ((t.tgtype)::integer & 66) ORDER BY t.tgname))::information_schema.cardinal_number AS action_order,
          (
              CASE
                  WHEN pg_has_role(c.relowner, 'USAGE'::text) THEN (regexp_match(pg_get_triggerdef(t.oid), '.{35,} WHEN \\((.+)\\) EXECUTE FUNCTION'::text))[1]
                  ELSE NULL::text
              END)::information_schema.character_data AS action_condition,
          (SUBSTRING(pg_get_triggerdef(t.oid) FROM (POSITION(('EXECUTE FUNCTION'::text) IN (SUBSTRING(pg_get_triggerdef(t.oid) FROM 48))) + 47)))::information_schema.character_data AS action_statement,
          (
              CASE ((t.tgtype)::integer & 1)
                  WHEN 1 THEN 'ROW'::text
                  ELSE 'STATEMENT'::text
              END)::information_schema.character_data AS action_orientation,
          (
              CASE ((t.tgtype)::integer & 66)
                  WHEN 2 THEN 'BEFORE'::text
                  WHEN 64 THEN 'INSTEAD OF'::text
                  ELSE 'AFTER'::text
              END)::information_schema.character_data AS action_timing,
          (t.tgoldtable)::information_schema.sql_identifier AS action_reference_old_table,
          (t.tgnewtable)::information_schema.sql_identifier AS action_reference_new_table,
          (NULL::name)::information_schema.sql_identifier AS action_reference_old_row,
          (NULL::name)::information_schema.sql_identifier AS action_reference_new_row,
          (NULL::timestamp with time zone)::information_schema.time_stamp AS created
         FROM pg_namespace n,
          pg_class c,
          pg_trigger t,
          ( VALUES (4,'INSERT'::text), (8,'DELETE'::text), (16,'UPDATE'::text)) em(num, text)
        WHERE ((n.oid = c.relnamespace) AND (c.oid = t.tgrelid) AND (((t.tgtype)::integer & em.num) <> 0) AND (NOT t.tgisinternal) AND (NOT pg_is_other_temp_schema(n.oid)) AND (pg_has_role(c.relowner, 'USAGE'::text) OR has_table_privilege(c.oid, 'INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'::text) OR has_any_column_privilege(c.oid, 'INSERT, UPDATE, REFERENCES'::text)));
        """), where);
    }

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

    /**
     * Create an aliased <code>information_schema.triggers</code> table
     * reference
     */
    public Triggers(Name alias) {
        this(alias, TRIGGERS);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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