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

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

There is a newer version: 1.9.0
Show newest version
package io.github.databob

import io.github.databob.Databob
import io.github.databob.Generator
import io.github.databob.Generators
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