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

com.dbobjekts.metadata.column.ForeignKeyColumns.kt Maven / Gradle / Ivy

There is a newer version: 0.6.0-RC2
Show newest version
package com.dbobjekts.metadata.column

import com.dbobjekts.api.AnyTable

class ForeignKeyLongColumn(
    table: AnyTable,
    name: String,
    override val parentColumn: Column,
    aggregateType: AggregateType?
) : LongColumn(table, name, aggregateType), IsMandatoryForeignKey {
    constructor(table: AnyTable, name: String, parentColumn: Column) : this(table, name, parentColumn, null)

    override val nullable = OptionalForeignKeyLongColumn(table, name, parentColumn, aggregateType)
    override fun distinct() = ForeignKeyLongColumn(table, nameInTable, parentColumn, AggregateType.DISTINCT)

    override val column: Column = this
}

class ForeignKeyIntColumn(table: AnyTable, name: String, override val parentColumn: Column, aggregateType: AggregateType?) :
    IntegerColumn(table, name, aggregateType), IsMandatoryForeignKey {
    constructor(table: AnyTable, name: String, parentColumn: Column) : this(table, name, parentColumn, null)

    override val nullable = NullableIntegerColumn(table, name, aggregateType)
    override fun distinct() = ForeignKeyIntColumn(table, nameInTable, parentColumn, AggregateType.DISTINCT)

    override val column: Column = this
}

class OptionalForeignKeyLongColumn(table: AnyTable, name: String, override val parentColumn: Column, aggregateType: AggregateType?) :
    NullableLongColumn(table, name, aggregateType), IsOptionalForeignKey {
    constructor(table: AnyTable, name: String, parentColumn: Column) : this(table, name, parentColumn, null)

    override val column: Column = this
}

class OptionalForeignKeyIntColumn(
    table: AnyTable,
    name: String,
    override val parentColumn: NonNullableColumn,
    aggregateType: AggregateType?
) : NullableIntegerColumn(table, name, aggregateType), IsOptionalForeignKey {
    constructor(table: AnyTable, name: String, parentColumn: NonNullableColumn) : this(table, name, parentColumn, null)

    override val column: Column = this
}

class ForeignKeyVarcharColumn(table: AnyTable, name: String, override val parentColumn: Column, aggregateType: AggregateType?) :
    VarcharColumn(table, name, aggregateType), IsMandatoryForeignKey {
    constructor(table: AnyTable, name: String, parentColumn: Column) : this(table, name, parentColumn, null)

    override val nullable = OptionalForeignKeyVarcharColumn(table, name, parentColumn, aggregateType)
    override fun distinct() = ForeignKeyVarcharColumn(table, nameInTable, parentColumn, AggregateType.DISTINCT)

    override val column: Column = this
}

class OptionalForeignKeyVarcharColumn(
    table: AnyTable,
    name: String,
    override val parentColumn: Column,
    aggregateType: AggregateType?
) : NullableVarcharColumn(table, name, aggregateType), IsOptionalForeignKey {
    constructor(table: AnyTable, name: String, parentColumn: Column) : this(table, name, parentColumn, null)
    override fun distinct() = OptionalForeignKeyVarcharColumn(table, nameInTable, parentColumn, AggregateType.DISTINCT)
    override val column: Column = this
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy