Cleanup classes from JDBC

This commit is contained in:
Andrew Golovashevich 2025-03-23 22:32:11 +03:00
parent fc29095e2b
commit cf5ba55950
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package ru.landgrafhomyak.db.raw_sql_skeleton
public class Namespace(
private val path: Array<String>
) {
private val usedNames = HashSet<String>()
public fun subNamespace(name: String): Namespace {
if (name in this.usedNames)
throw IllegalArgumentException("Name is already used: $name")
this.usedNames.add(name)
return Namespace(this.path + name)
}
public fun table(name: String): TableName {
if (name in this.usedNames)
throw IllegalArgumentException("Name is already used: $name")
this.usedNames.add(name)
return TableName(this.formatTableName(name))
}
private fun formatTableName(name: String) = this.path.joinToString(prefix = "::", separator = "::", postfix = "::${name}")
}

View File

@ -0,0 +1,7 @@
package ru.landgrafhomyak.db.raw_sql_skeleton
public class TableName(private val name: String) {
public val asSqlReference: String = "\"${this.name}\""
public val asSqlString: String = "\'${this.name}\'"
override fun toString(): String = this.asSqlReference
}