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

io.github.databob.LanguageConstructsGenerator.kt Maven / Gradle / Ivy

The newest version!
package io.github.databob

import java.lang.reflect.Type

class LanguageConstructsGenerator : Generator {

    private val generator = CompositeGenerator(
        Generators.ofType { d -> Exception(d.mk()) },
        Generators.ofType { d -> RuntimeException(d.mk()) },
        object : Generator {
            override fun mk(type: Type, databob: Databob): Any? = when {
                Class.forName(type.typeName).isEnum -> Class.forName(type.typeName).enumConstants[0]
                else -> null
            }
        }
    )

    override fun mk(type: Type, databob: Databob): Any? = generator.mk(type, databob)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy