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

com.qxml.transform.generate.tools.GenReportTool.kt Maven / Gradle / Ivy

package com.qxml.transform.generate.tools

import com.qxml.tools.LayoutTypeNameCorrect
import com.qxml.transform.generate.GenResult
import com.qxml.transform.generate.ViewGenResultInfo
import java.io.File
import java.lang.StringBuilder

object GenReportTool {

    private const val TABLE_HEAD = "\n" +
            "\n" +
            "\n" +
            "        \n" +
            "    "


    @JvmStatic
    fun genReport(reportFile: File, genResultMap: Map>) {
        if (!reportFile.parentFile.exists()) {
            reportFile.parentFile.mkdirs()
        }
        if (!reportFile.exists()) {
            reportFile.createNewFile()
        }
        val stringBuilder = StringBuilder()
        stringBuilder.append(TABLE_HEAD).append("\n")
        genResultMap.forEach { (layoutName, hashMap) ->
            var firstLine = true
            hashMap.forEach { (layoutType, viewGenResultInfo) ->
                val firstClo = if (firstLine) {
                    firstLine = false
                    ""
                } else ""
                val bgColor = if (viewGenResultInfo.result == GenResult.SUCCESS) "#ffffff" else "#fe2047"
                stringBuilder.append("\n" +
                        "        ${firstClo}\n" +
                        "    \n")
            }
        }
        stringBuilder.append("
LayoutNameLayoutTypeInfo
${layoutName}
${LayoutTypeNameCorrect.toDisplayText(layoutType)}${viewGenResultInfo.info}
") reportFile.writeText(stringBuilder.toString()) } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy