All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ufoss.kotysa.SqlClientSubQuery.kt Maven / Gradle / Ivy

/*
 * This is free and unencumbered software released into the public domain, following 
 */

package org.ufoss.kotysa

import org.ufoss.kotysa.columns.TsvectorColumn
import org.ufoss.kotysa.postgresql.Tsquery
import java.math.BigDecimal

public class SqlClientSubQuery private constructor() {

    public interface SingleScope : SqlClientQuery.SelectableSingle {
        override fun  select(column: Column<*, T>): Fromable
        override fun  selectCount(column: Column<*, T>?): Fromable
        override fun  selectDistinct(column: Column<*, T>): Fromable
        override fun  selectMin(column: MinMaxColumn<*, T>): Fromable
        override fun  selectMax(column: MinMaxColumn<*, T>): Fromable
        override fun  selectAvg(column: NumericColumn<*, T>): Fromable
        override fun selectSum(column: IntColumn<*>): Fromable
        override fun selectTsRankCd(tsvectorColumn: TsvectorColumn<*>, tsquery: Tsquery): Fromable
    }

    public interface Scope : SingleScope, SqlClientQuery.Selectable {
        override fun  select(column: Column<*, T>): FirstSelect
        override fun  select(table: Table): FirstSelect
        override fun  selectCount(column: Column<*, T>?): FirstSelect
        override fun  selectDistinct(column: Column<*, T>): FirstSelect
        override fun  selectMin(column: MinMaxColumn<*, T>): FirstSelect
        override fun  selectMax(column: MinMaxColumn<*, T>): FirstSelect
        override fun  selectAvg(column: NumericColumn<*, T>): FirstSelect
        override fun selectSum(column: IntColumn<*>): FirstSelect
        override fun selectTsRankCd(tsvectorColumn: TsvectorColumn<*>, tsquery: Tsquery): FirstSelect
        override fun  selectCaseWhenExists(
            dsl: SingleScope.() -> Return
        ): SelectCaseWhenExistsFirst
        override fun  selectStarFromSubQuery(
            dsl: Scope.() -> Return
        ): From
    }

    public interface SelectCaseWhenExistsFirst : SqlClientQuery.SelectCaseWhenExists {
        override fun  then(value: U): SelectCaseWhenExistsFirstPart2
    }

    public interface SelectCaseWhenExistsFirstPart2 : SqlClientQuery.SelectCaseWhenExistsPart2 {
        override fun `else`(value: U): FirstSelect
    }

    public interface Fromable : SqlClientQuery.Select, SqlClientQuery.Fromable {
        override fun  from(table: Table): FromTable
        override fun  from(dsl: Scope.() -> Return): From
        override fun from(tsquery: Tsquery): From

        override fun `as`(alias: String): Fromable
    }

    public interface FirstSelect : Fromable, SqlClientQuery.Select, SqlClientQuery.Andable {
        override fun  and(column: Column<*, U>): SecondSelect
        override fun  and(table: Table): SecondSelect
        override fun  andCount(column: Column<*, U>): SecondSelect
        override fun  andDistinct(column: Column<*, U>): SecondSelect
        override fun  andMin(column: MinMaxColumn<*, U>): SecondSelect
        override fun  andMax(column: MinMaxColumn<*, U>): SecondSelect
        override fun  andAvg(column: NumericColumn<*, U>): SecondSelect
        override fun andSum(column: IntColumn<*>): SecondSelect
        override fun andTsRankCd(tsvectorColumn: TsvectorColumn<*>, tsquery: Tsquery): SecondSelect
        override fun  and(dsl: Scope.() -> Return)
                : SecondSelect

        override fun  andCaseWhenExists(
            dsl: SingleScope.() -> Return
        ): AndCaseWhenExistsSecond

        override fun `as`(alias: String): FirstSelect
    }

    public interface AndCaseWhenExistsSecond : SqlClientQuery.AndCaseWhenExists {
        override fun  then(value: V): AndCaseWhenExistsSecondPart2
    }

    public interface AndCaseWhenExistsSecondPart2 :
        SqlClientQuery.AndCaseWhenExistsPart2 {
        override fun `else`(value: V): SecondSelect
    }

    public interface SecondSelect : Fromable>, SqlClientQuery.Andable {
        override fun  and(column: Column<*, V>): ThirdSelect
        override fun  and(table: Table): ThirdSelect
        override fun  andCount(column: Column<*, V>): ThirdSelect
        override fun  andDistinct(column: Column<*, V>): ThirdSelect
        override fun  andMin(column: MinMaxColumn<*, V>): ThirdSelect
        override fun  andMax(column: MinMaxColumn<*, V>): ThirdSelect
        override fun  andAvg(column: NumericColumn<*, V>): ThirdSelect
        override fun andSum(column: IntColumn<*>): ThirdSelect
        override fun andTsRankCd(tsvectorColumn: TsvectorColumn<*>, tsquery: Tsquery): ThirdSelect
        override fun  and(dsl: Scope.() -> Return)
                : ThirdSelect

        override fun  andCaseWhenExists(dsl: SingleScope.() -> Return)
                : AndCaseWhenExistsThird

        override fun `as`(alias: String): SecondSelect
    }

    public interface AndCaseWhenExistsThird : SqlClientQuery.AndCaseWhenExists {
        override fun  then(value: W): AndCaseWhenExistsThirdPart2
    }

    public interface AndCaseWhenExistsThirdPart2 : SqlClientQuery.AndCaseWhenExistsPart2 {
        override fun `else`(value: W): ThirdSelect
    }

    public interface ThirdSelect : Fromable>, SqlClientQuery.Andable {
        override fun  and(column: Column<*, W>): Select
        override fun  and(table: Table): Select
        override fun  andCount(column: Column<*, W>): Select
        override fun  andDistinct(column: Column<*, W>): Select
        override fun  andMin(column: MinMaxColumn<*, W>): Select
        override fun  andMax(column: MinMaxColumn<*, W>): Select
        override fun  andAvg(column: NumericColumn<*, W>): Select
        override fun andSum(column: IntColumn<*>): Select
        override fun andTsRankCd(tsvectorColumn: TsvectorColumn<*>, tsquery: Tsquery): Select
        override fun  and(dsl: Scope.() -> Return): Select
        override fun  andCaseWhenExists(
            dsl: SingleScope.() -> Return
        ): AndCaseWhenExistsLast

        override fun `as`(alias: String): ThirdSelect
    }

    public interface AndCaseWhenExistsLast : SqlClientQuery.AndCaseWhenExists {
        override fun  then(value: U): AndCaseWhenExistsLastPart2
    }

    public interface AndCaseWhenExistsLastPart2 : SqlClientQuery.AndCaseWhenExistsPart2 {
        override fun `else`(value: U): Select
    }

    public interface Select : Fromable>, SqlClientQuery.Andable {
        override fun  and(column: Column<*, T>): Select
        override fun  and(table: Table): Select
        override fun  andCount(column: Column<*, T>): Select
        override fun  andDistinct(column: Column<*, T>): Select
        override fun  andMin(column: MinMaxColumn<*, T>): Select
        override fun  andMax(column: MinMaxColumn<*, T>): Select
        override fun  andAvg(column: NumericColumn<*, T>): Select
        override fun andSum(column: IntColumn<*>): Select
        override fun andTsRankCd(tsvectorColumn: TsvectorColumn<*>, tsquery: Tsquery): Select
        override fun  and(dsl: Scope.() -> Return): Select
        override fun  andCaseWhenExists(
            dsl: SingleScope.() -> Return
        ): AndCaseWhenExistsLast

        override fun `as`(alias: String): Select
    }

    public interface From : SqlClientQuery.From>, SqlClientQuery.Whereable>, GroupBy,
        LimitOffset, Return {
        override fun  and(table: Table): FromTable
        override fun  and(dsl: Scope.() -> Return): From
        override fun and(tsquery: Tsquery): From
    }

    public interface FromTable : SqlClientQuery.FromTable>,
        SqlClientQuery.From>, From, SqlClientQuery.Whereable>, GroupBy, LimitOffset, Return

    public interface Where : SqlClientQuery.Where>, GroupBy, LimitOffset, Return

    public interface GroupBy : SqlClientQuery.GroupBy>

    public interface GroupByPart2 : SqlClientQuery.GroupByPart2>, LimitOffset, Return

    public interface LimitOffset : SqlClientQuery.LimitOffset>, Return

    public interface Return {
        public fun sql(parentProperties: DefaultSqlClientCommon.Properties): String
    }
}