Cleanup classes from JDBC
This commit is contained in:
parent
fc29095e2b
commit
cf5ba55950
@ -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}")
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user