override fun generateClass()

in aspoet/src/main/kotlin/com/google/androidstudiopoet/generators/packages/KotlinGenerator.kt [26:48]


    override fun generateClass(blueprint: ClassBlueprint) {
        val buff = StringBuilder()

        buff.append("package ${blueprint.packageName};\n\n")

        val annotName = blueprint.className + "Fancy"
        buff.append("annotation class " + annotName + "\n")
        buff.append("@" + annotName + "\n")

        buff.append("class ${blueprint.className} {\n")

        blueprint.getFieldBlueprints()
                .joinToString(separator = "\n", postfix = "\n") { it ->  "val ${it.name}: ${it.typeName}? = null"}
                .let { buff.append(it) }

        blueprint.getMethodBlueprints()
                .withIndex().map { (if (it.index != 0) "\n" else "") + generateMethod(it.value) }
                .fold(buff) { acc, method -> acc.append(method) }

        buff.append("}")

        writeFile(blueprint.getClassPath(), buff.toString())
    }