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

com.sxtanna.db.KueryTaskTable.kt Maven / Gradle / Ivy

There is a newer version: 1.6
Show newest version
package com.sxtanna.db

import com.sxtanna.db.ext.Value
import com.sxtanna.db.struct.Table
import com.sxtanna.db.struct.base.Duplicate
import com.sxtanna.db.struct.statement.*
import kotlin.reflect.KProperty1

/**
 * A [KueryTask] specific for the supplied [Table]
 */
class KueryTaskTable(private val table : Table, val task : KueryTask) : DBCreator.TableCreator, DBDeleter.TableDeleter, DBDropper.TableDropper, DBInserter.TableInserter, DBSelector.TableSelector, DBTruncater.TableTruncater, DBUpdater.TableUpdater {

    //region Create statement
    override fun create() = task.create(table)
    //endregion


    //region Delete statements
    override fun delete() : Delete {
        return task.delete(table)
    }

    override fun delete(rows : Collection) {
        task.delete(table, rows)
    }

    override fun deleteAllRows() {
        task.deleteAllRows(table)
    }
    //endregion


    //region Drop statement
    override fun drop() {
        task.drop(table)
    }
    //endregion


    //region Insert statements
    override fun insert(rows : Collection) {
        task.insert(table, rows)
    }

    override fun insert(duplicate : Duplicate>, rows : Collection) {
        task.insert(table, duplicate, rows)
    }
    //endregion


    //region Select statements
    override fun select() = task.select(table)

    override fun 
          select(prop : KProperty1) = task.select(table, prop)

    override fun 
          select(prop1 : KProperty1,
                 prop2 : KProperty1) = task.select(table, prop1, prop2)

    override fun 
          select(prop1 : KProperty1,
                 prop2 : KProperty1,
                 prop3 : KProperty1) = task.select(table, prop1, prop2, prop3)

    override fun 
          select(prop1 : KProperty1,
                 prop2 : KProperty1,
                 prop3 : KProperty1,
                 prop4 : KProperty1) = task.select(table, prop1, prop2, prop3, prop4)

    override fun 
          select(prop1 : KProperty1,
                 prop2 : KProperty1,
                 prop3 : KProperty1,
                 prop4 : KProperty1,
                 prop5 : KProperty1) = task.select(table, prop1, prop2, prop3, prop4, prop5)
    //endregion


    //region Truncate statement
    override fun truncate() {
        task.truncate(table)
    }
    //endregion


    //region Update statements
    override fun update() : Update = task.update(table)

    override fun update(rows : Collection) = task.update(table, rows)

    override fun update(vararg values : Value) = task.update(table, *values)

    override fun updateAllRows(row : T) {
        task.updateAllRows(table, row)
    }

    override fun updateAllRows(vararg values : Value) {
        task.updateAllRows(table, *values)
    }
    //endregion

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy