Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.
/ kGen Public archive

kGen is a Kotlin DSL for generating .kt source files

License

Notifications You must be signed in to change notification settings

alexxxdev/kGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

kGen

kGen is a Kotlin DSL for generating .kt source files

example:

val file = File("src")
kotlinFile("ru.alexxxdev.sample", "Test") {
        indent = "\t"

        +import(String::class)
        +import(ClassName.get(File::class))

        field("field1", MUTABLE, NULLABLE) {
            className = ClassName.get(File::class)
            "null"
        }

        field("field2") {
            +Modifier.PRIVATE
            "0"
        }

        method("fun2") {
            +import(String::class)
            +"val s = \"123\""
            returns(ClassName.get(String::class)){ "s"  }
        }

        method("fun1", Modifier.INTERNAL) {
            returns{ "\"test\""	}
        }

        kotlinClass("Class1") {
            +Modifier.PRIVATE
            +import(String::class)

            field("field11", MUTABLE, NULLABLE) {
                className = ClassName.get(File::class)
                "null"
            }

            method("fun11") {
                +Modifier.INTERNAL
                returns{ "\"test\""	}
            }
        }

        kotlinInterface("Interface1") {
        }

        kotlinObject("Object1") {
        }

    }.writeTo(file)

About

kGen is a Kotlin DSL for generating .kt source files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages