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

com.spirytusz.spi.weaver.transform.scan.base.AbstractInputScanner.kt Maven / Gradle / Ivy

There is a newer version: 0.0.2
Show newest version
package com.spirytusz.spi.weaver.transform.scan.base

import com.spirytusz.spi.weaver.transform.data.ServiceImplInfo
import com.spirytusz.spi.weaver.transform.data.ServiceInfo
import org.apache.commons.codec.digest.DigestUtils

abstract class AbstractInputScanner : IInputScanner {
    override val serviceMapping: Map>
        get() = computeServiceMapping()

    protected val serviceInfoList = mutableListOf()
    protected val serviceImplInfoList = mutableListOf()

    protected fun String.computeDstFileName(): String {
        return DigestUtils.md5Hex(this)
    }

    private fun computeServiceMapping(): Map> {
        return serviceInfoList.mapNotNull { serviceInfo ->
            val serviceInfoImpls = serviceImplInfoList.filter {
                it.implements.contains(serviceInfo.className)
            }
            if (serviceInfoImpls.isNotEmpty()) {
                serviceInfo to serviceInfoImpls
            } else {
                null
            }
        }.toMap()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy