-
Notifications
You must be signed in to change notification settings - Fork 2
/
ColumnType.kt
46 lines (43 loc) · 1.27 KB
/
ColumnType.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package dev.inmo.micro_utils.repos
sealed class ColumnType(
typeName: String,
nullable: Boolean
) {
open val asType: String = "$typeName${if (!nullable) " not null" else ""}"
sealed class Text(
nullable: Boolean
) : ColumnType("text", nullable) {
object NULLABLE : Text(true)
object NOT_NULLABLE : Text(false)
}
sealed class Numeric(
typeName: String,
autoincrement: Boolean = false,
primaryKey: Boolean = false,
nullable: Boolean = false
) : ColumnType(
typeName,
nullable
) {
override val asType: String = "${super.asType}${if (primaryKey) " primary key" else ""}${if (autoincrement) " autoincrement" else ""}"
class INTEGER(
autoincrement: Boolean = false,
primaryKey: Boolean = false,
nullable: Boolean = false
) : Numeric(
"integer",
autoincrement,
primaryKey,
nullable
)
class DOUBLE(autoincrement: Boolean = false, primaryKey: Boolean = false, nullable: Boolean = false) : Numeric(
"double",
autoincrement,
primaryKey,
nullable
)
}
override fun toString(): String {
return asType
}
}