/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.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.metrics.Metrics;
import ru.micord.webbpm.ervu.business_metrics.db_beans.metrics.tables.records.ViewCriminalAdministrativeLiabilityRecord;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>metrics.view_criminal_administrative_liability</code>
     */
    public static final ViewCriminalAdministrativeLiability VIEW_CRIMINAL_ADMINISTRATIVE_LIABILITY = new ViewCriminalAdministrativeLiability();

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

    /**
     * The column
     * <code>metrics.view_criminal_administrative_liability.criminal_administrative_liability_id</code>.
     */
    public final TableField<ViewCriminalAdministrativeLiabilityRecord, Long> CRIMINAL_ADMINISTRATIVE_LIABILITY_ID = createField(DSL.name("criminal_administrative_liability_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>metrics.view_criminal_administrative_liability.percent_criminal</code>.
     */
    public final TableField<ViewCriminalAdministrativeLiabilityRecord, BigDecimal> PERCENT_CRIMINAL = createField(DSL.name("percent_criminal"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>metrics.view_criminal_administrative_liability.percent_administrative</code>.
     */
    public final TableField<ViewCriminalAdministrativeLiabilityRecord, BigDecimal> PERCENT_ADMINISTRATIVE = createField(DSL.name("percent_administrative"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>metrics.view_criminal_administrative_liability.count_without_criminal</code>.
     */
    public final TableField<ViewCriminalAdministrativeLiabilityRecord, Long> COUNT_WITHOUT_CRIMINAL = createField(DSL.name("count_without_criminal"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>metrics.view_criminal_administrative_liability.count_without_administrative</code>.
     */
    public final TableField<ViewCriminalAdministrativeLiabilityRecord, Long> COUNT_WITHOUT_ADMINISTRATIVE = createField(DSL.name("count_without_administrative"), SQLDataType.BIGINT, this, "");

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

    private ViewCriminalAdministrativeLiability(Name alias, Table<ViewCriminalAdministrativeLiabilityRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_criminal_administrative_liability" as  SELECT criminal_administrative_liability.criminal_administrative_liability_id,
         COALESCE(round((((criminal_administrative_liability.count_criminal)::numeric * (100)::numeric) / NULLIF((criminal_administrative_liability.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_criminal,
         COALESCE(round((((criminal_administrative_liability.count_administrative)::numeric * (100)::numeric) / NULLIF((criminal_administrative_liability.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_administrative,
         (criminal_administrative_liability.count_all - criminal_administrative_liability.count_criminal) AS count_without_criminal,
         (criminal_administrative_liability.count_all - criminal_administrative_liability.count_administrative) AS count_without_administrative
        FROM metrics.criminal_administrative_liability;
        """), where);
    }

    /**
     * Create an aliased
     * <code>metrics.view_criminal_administrative_liability</code> table
     * reference
     */
    public ViewCriminalAdministrativeLiability(String alias) {
        this(DSL.name(alias), VIEW_CRIMINAL_ADMINISTRATIVE_LIABILITY);
    }

    /**
     * Create an aliased
     * <code>metrics.view_criminal_administrative_liability</code> table
     * reference
     */
    public ViewCriminalAdministrativeLiability(Name alias) {
        this(alias, VIEW_CRIMINAL_ADMINISTRATIVE_LIABILITY);
    }

    /**
     * Create a <code>metrics.view_criminal_administrative_liability</code>
     * table reference
     */
    public ViewCriminalAdministrativeLiability() {
        this(DSL.name("view_criminal_administrative_liability"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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