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

com.sxtanna.database.struct.Resolver.kt Maven / Gradle / Ivy

There is a newer version: 3.0-beta
Show newest version
package com.sxtanna.database.struct

import com.sxtanna.database.ext.*
import com.sxtanna.database.struct.obj.*
import java.math.BigInteger
import java.sql.Timestamp
import java.util.*
import kotlin.Byte
import kotlin.Double
import kotlin.Enum
import kotlin.Float
import kotlin.Int
import kotlin.Long
import kotlin.Short
import kotlin.String
import kotlin.reflect.KClass
import kotlin.reflect.KProperty1
import kotlin.reflect.full.findAnnotation
import kotlin.reflect.full.isSubclassOf
import kotlin.reflect.jvm.jvmErasure

object Resolver {

	private val adapters = mutableMapOf, Adapter>()


	init {
		this[Char::class] = { SqlType.Char(1, isPrimaryKey(), isNotNull()) }
		this[UUID::class] = { SqlType.Char(36, isPrimaryKey(), isNotNull()) }

		this[Boolean::class] = { SqlType.Bool(isPrimaryKey(), isNotNull()) }

		this[Enum::class] = {
			if (isSerialized()) SqlType.VarChar(VARCHAR_SIZE, isPrimaryKey(), isNotNull())
			else {
				@Suppress("UNCHECKED_CAST")
				SqlType.EnumSet(returnType.jvmErasure as KClass>, isPrimaryKey(), isNotNull())
			}
		}

		this[Timestamp::class] = {
			val time = findAnnotation




© 2015 - 2024 Weber Informatics LLC | Privacy Policy