com.bennyhuo.tieguanyin.compiler.basic.builder.BasicConstantBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compiler Show documentation
Show all versions of compiler Show documentation
An Activity & Fragment builder to make it easier and safer to start a new page.
The newest version!
package com.bennyhuo.tieguanyin.compiler.basic.builder
import com.bennyhuo.tieguanyin.compiler.basic.BasicClass
import com.bennyhuo.tieguanyin.compiler.utils.camelToUnderline
import com.squareup.javapoet.FieldSpec
import com.squareup.javapoet.TypeSpec
import javax.lang.model.element.Modifier
abstract class BasicConstantBuilder(private val basicClass: BasicClass) {
open fun build(typeBuilder: TypeSpec.Builder) {
basicClass.fields.forEach { field ->
typeBuilder.addField(FieldSpec.builder(String::class.java,
field.prefix + field.name.camelToUnderline(),
Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
.initializer("\$S", field.name)
.build())
}
}
}