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

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

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

package org.ufoss.kotysa

import kotlin.reflect.KClass

/**
 * A database Table model mapped by entity class [tableClass]
 */
public interface KotysaTable {
    public val tableClass: KClass
    public val table: Table

    /**
     * Real name of this table in the database
     */
    public val name: String
    public val columns: List>
    public val primaryKey: PrimaryKey
    public val foreignKeys: Set>
    public val kotysaIndexes: Set>
    
    public val dbColumns: List> get() = columns.filterIsInstance>()
}


internal class KotysaTableImpl internal constructor(
    override val tableClass: KClass,
    override val table: Table,
    override val name: String,
    override val columns: List>,
    override val primaryKey: PrimaryKey,
    override val foreignKeys: Set>,
    override val kotysaIndexes: Set>,
) : KotysaTable {

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as KotysaTableImpl<*>

        if (name != other.name) return false

        return true
    }

    override fun hashCode(): Int {
        return name.hashCode()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy