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

com.antwerkz.critter.CritterContext.kt Maven / Gradle / Ivy

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

import java.io.File

@Suppress("UNCHECKED_CAST")
class CritterContext(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(critterClass: CritterClass) {
        critterClass.context = this
        classes["${critterClass.pkgName}.${critterClass.name}"] = critterClass
    }

/*
    fun lookup(name: String): CritterClass? {
        var className: String
        var pkgName: String = null

        if (name.contains(".")) {

        } else {
            className = name
        }

        return resolve(pkgName, className)
    }
*/

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy