This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package work.beltran.sample | |
| class Generated_Hello { | |
| fun getName() = "World" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'kotlin' | |
| repositories { | |
| mavenCentral() | |
| } | |
| dependencies { | |
| compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" | |
| compile 'com.squareup:kotlinpoet:0.5.0' | |
| compile "com.google.auto.service:auto-service:1.0-rc2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package work.beltran.sample | |
| import com.google.auto.service.AutoService | |
| import com.squareup.kotlinpoet.FileSpec | |
| import com.squareup.kotlinpoet.FunSpec | |
| import com.squareup.kotlinpoet.TypeSpec | |
| import java.io.File | |
| import javax.annotation.processing.* | |
| import javax.lang.model.SourceVersion | |
| import javax.lang.model.element.TypeElement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'kotlin' | |
| kapt { | |
| generateStubs = true | |
| } | |
| repositories { | |
| mavenCentral() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package work.beltran.sample | |
| @GenName | |
| class Hello | |
| fun main(args: Array<String>) { | |
| println("Hello ${Generated_Hello().getName()}") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package work.beltran.sample | |
| annotation class GenName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rootProject.name = 'kotlin-code-gen-sample' | |
| include 'generator' | |
| include 'sample-main' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| group 'beltran.work' | |
| version '1.0-SNAPSHOT' | |
| buildscript { | |
| ext.kotlin_version = '1.1.3-2' | |
| repositories { | |
| mavenCentral() | |
| } | |
| dependencies { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import kotlin.reflect.full.findAnnotation | |
| annotation class HelloName(val name: String) | |
| abstract class Hello { | |
| fun getName(): String { | |
| val ann = javaClass.kotlin.findAnnotation<HelloName>() | |
| return ann?.name ?: throw IllegalStateException("Missing annotation @HelloName") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class DayViewHolder extends ViewHolder { | |
| @NotNull | |
| private final TextView title; | |
| @NotNull | |
| public final TextView getTitle() { | |
| return this.title; | |
| } | |
| public final void bind(@NotNull Day day) { |