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

com.antwerkz.critter.kotlin.KotlinContext.kt Maven / Gradle / Ivy

There is a newer version: 3.0.5
Show newest version
package com.antwerkz.critter.kotlin

import java.io.File

@Suppress("UNCHECKED_CAST")
class KotlinContext(val criteriaPkg: String? = null, var force: Boolean = false) {
    val classes = mutableMapOf()

    fun shouldGenerate(source: Long?, output: Long?): Boolean {
        return force || source == null || output == null || output <= source
    }

    fun add(clazz: KotlinClass) {
        clazz.context = this
        classes["${clazz.fileSpec.packageName}.${clazz.name}"] = clazz
    }

    fun resolve(currentPkg: String? = null, name: String): KotlinClass? {
        return classes[name] ?: currentPkg?.let { classes["$currentPkg.$name"] }
    }

    fun resolveFile(name: String): File? {
        return classes[name]?.file
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy