/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.registration_change_address.tables;


import java.math.BigDecimal;
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;

import ru.micord.webbpm.ervu.business_metrics.db_beans.registration_change_address.RegistrationChangeAddress;
import ru.micord.webbpm.ervu.business_metrics.db_beans.registration_change_address.tables.records.ViewImpositionTmpMeasuresRecord;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>registration_change_address.view_imposition_tmp_measures</code>
     */
    public static final ViewImpositionTmpMeasures VIEW_IMPOSITION_TMP_MEASURES = new ViewImpositionTmpMeasures();

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

    /**
     * The column
     * <code>registration_change_address.view_imposition_tmp_measures.imposition_tmp_measures_id</code>.
     */
    public final TableField<ViewImpositionTmpMeasuresRecord, Long> IMPOSITION_TMP_MEASURES_ID = createField(DSL.name("imposition_tmp_measures_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>registration_change_address.view_imposition_tmp_measures.count_all</code>.
     */
    public final TableField<ViewImpositionTmpMeasuresRecord, Long> COUNT_ALL = createField(DSL.name("count_all"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>registration_change_address.view_imposition_tmp_measures.percent_refused_in_second</code>.
     */
    public final TableField<ViewImpositionTmpMeasuresRecord, BigDecimal> PERCENT_REFUSED_IN_SECOND = createField(DSL.name("percent_refused_in_second"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_imposition_tmp_measures.percent_accepted_in_second</code>.
     */
    public final TableField<ViewImpositionTmpMeasuresRecord, BigDecimal> PERCENT_ACCEPTED_IN_SECOND = createField(DSL.name("percent_accepted_in_second"), SQLDataType.NUMERIC, this, "");

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

    private ViewImpositionTmpMeasures(Name alias, Table<ViewImpositionTmpMeasuresRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_imposition_tmp_measures" as  SELECT imposition_tmp_measures.imposition_tmp_measures_id,
         (imposition_tmp_measures.count_refused_in_second + imposition_tmp_measures.count_accepted_in_second) AS count_all,
         COALESCE(round((((imposition_tmp_measures.count_refused_in_second)::numeric * (100)::numeric) / NULLIF(((imposition_tmp_measures.count_refused_in_second + imposition_tmp_measures.count_accepted_in_second))::numeric, (0)::numeric))), (0)::numeric) AS percent_refused_in_second,
         COALESCE(round((((imposition_tmp_measures.count_accepted_in_second)::numeric * (100)::numeric) / NULLIF(((imposition_tmp_measures.count_refused_in_second + imposition_tmp_measures.count_accepted_in_second))::numeric, (0)::numeric))), (0)::numeric) AS percent_accepted_in_second
        FROM registration_change_address.imposition_tmp_measures;
        """), where);
    }

    /**
     * Create an aliased
     * <code>registration_change_address.view_imposition_tmp_measures</code>
     * table reference
     */
    public ViewImpositionTmpMeasures(String alias) {
        this(DSL.name(alias), VIEW_IMPOSITION_TMP_MEASURES);
    }

    /**
     * Create an aliased
     * <code>registration_change_address.view_imposition_tmp_measures</code>
     * table reference
     */
    public ViewImpositionTmpMeasures(Name alias) {
        this(alias, VIEW_IMPOSITION_TMP_MEASURES);
    }

    /**
     * Create a
     * <code>registration_change_address.view_imposition_tmp_measures</code>
     * table reference
     */
    public ViewImpositionTmpMeasures() {
        this(DSL.name("view_imposition_tmp_measures"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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